7 Useful Git Commands

  1. git pull
  2. git status
  3. git diff
  4. git checkout
  5. git add
  6. git commit -m 'fix: bug'
  7. git push

Introduction

Git is an important part of daily programming (especially if you're working with a team) and is widely used in the software industry. Since there are many various commands you can use, mastering Git takes time. But some commands are used more frequently (some daily). So in this post, we will see the 7 most used Git commands that every developer should know.

Note: To understand this article, you need to know the basics of Git.

Useful Git Commands

  1. git pull: In a folder, to pull the complete content of the repository to a particular folder.

    Ex:- /test>$ git pull

  2. git status: To see the present status of the git.

    Ex:- /test>$ git status

  3. git diff: To see what all changes have been done in all files.

    Ex:- /test>$ git diff

    To see what all changes have been done in a particular file.

    Ex:- /test>$ git diff css/main.css

  4. git checkout: To retain old values or content in the git.

    Ex:- /test>$ git checkout

    To retain what all changes have been done in a particular file.

    Ex:- /test>$ git checkout css/main.css

  5. git add: To add all changes have been done in the git.

    Ex:- /test>$ git add .

  6. git commit: To commit all changes have been done in the git with a message.

    Ex:- /test>$ git commit -m 'fix: changes' .

  7. git push: To push all changes have been done in the git to the server.

    Ex:- /test>$ git push