DEV Community

Cover image for Git Commands Every Developer Should Know
Albérico Junior
Albérico Junior

Posted on

Git Commands Every Developer Should Know

Hello cousins and cousins, how are you?

Come check out these quick git command tips.

I believe you should use some of these commands every day.

  1. git init This is the command used to initialize a project as a git repository.
  2. git remote add origin This is the command used to add or connect to a remote repository.
  3. git remote This is the command used to view connected remote repositories.
  4. git status This command is used to view the status of files in your local repository.
  5. git add This command is used to prepare modified or untracked files.
  6. git reset This command is used to remove files.
  7. git commit This command is used to commit tested files and provide a confirmation message after testing.
  8. git push -u origin This command is used to push committed files to the GitHub repository.
  9. git fetch This command is used to fetch the most up-to-date version from your local repository. It checks for new files or new branches.
  10. git pull This command is used to take the information you just fetched and pull it into your local repository. It updates your local repository to the most up-to-date version.
  11. git branch This command is used to view the branch you are currently on.
  12. git merge This command is used to merge two branches. To do this, enter the branch you want to inherit the changes from.

Which of these commands do you use the most in your daily life, and if you felt high from any command, leave it in the comments.

Top comments (7)

Collapse
 
bendecoste profile image
Benjamin DeCoste

I would add git add -p to this list. You can add your changes in parts (in case there are parts you do not wish to commit. Also, -p works with all sorts of other git commands.

git rebase is another critical command, but it is more advanced.

Collapse
 
byt3h3ad profile image
Adhiraj Dutta • Edited

great article for beginners! i would like to add the git reflog which does the opposite of git reset. know more about it here.

Collapse
 
lubustos profile image
LuBustos

Nice post, I would add git stash which save your changes in a stash list (this command saves your local modifications away and reverts the working directory to match the HEAD commit) and then you can recover it using git stash pop

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

Personally I use the git cli as little as possible.

When I do use it, the only command I do remember is

$ tldr git-<TAB>
$ tldr git-log
Enter fullscreen mode Exit fullscreen mode

See tldr.sh/

Collapse
 
jrtibbetts profile image
Jason R Tibbetts

Lol, tldr looks neat.

Collapse
 
saimwebhr profile image
Muhammad Saim Hashmi

It would have been more readable if you had bold the commands, or kept them in double quotes. Like this.

  1. git init This is the command used to initialize a project as a git repository.
Collapse
 
riju_bro profile image
riju_bro • Edited

The git command I use the most in my daily life: git clone 😅
Good for Beginners 👍