DEV Community

Cover image for Git Commands Every Dev MUST know
Mursal Furqan Kumbhar
Mursal Furqan Kumbhar

Posted on

Git Commands Every Dev MUST know

Hello and Good Morning ☕
I know I had not been writing lately, but now I am back on my writing spree 🎉
Today we are going to see some awesome git commands, that every developer MUST know. Look carefully when I stress on the word MUST. Knowing these commands would definitely make your time easier. 😉
So let's start.

  • Initialize local git repository

git init

  • Add a particular file to a repository

git add

  • Add all uncommitted files to the repository

git add .

  • Set Repository

git config --global 'mursalfk'
git config --global ''

  • Add message to your commit

git commit -m "You can add a message to your commit like this"

  • See commit history

git log

  • Add remote Name/URL

git remote add origin ''

  • Push your changes to remote repository

git push origin master

  • Clone any repository

git clone ''

  • Update the current working directory

git pull origin master

Tired already? Come on... It's not that long 😉
Image description

  • Check difference in between commits

git diff HEAD~1 HEAD

  • Download files from any repository

git fetch origin master

  • Create a new branch

git branch branchName

  • Create a new branch inside a folder

git branch branchFolder/branchName

  • Switch to another branch

git checkout branchName

  • Switch to another branch present in another folder

git checkout branchFolder/branchName

  • Create and checkout to the new branch at the same time

git checkout -b branchName

  • Create and checkout to the new branch present in another folder at the same time

git checkout branchFolder/branchName

  • Merge to a new branch

git merge master

Discussion (3)

attaullahshafiq10 profile image
Hafiz Muhammad Attaullah

Good lala...

mahnoor2020 profile image
Mahnoor Naveed

Much Needed 🙌

nepster23 profile image
Rojil Shrestha

nice one