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 com…


This content originally appeared on DEV Community and was authored by Mursal Furqan

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 git_commands.md

  • Add all uncommitted files to the repository

git add .

  • Set Repository

git config --global user.name 'mursalfk'
git config --global user.email 'mursalfurqan@gmail.com'

  • 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 'https://github.com/mursalfk/mursalfk.git'

  • Push your changes to remote repository

git push origin master

  • Clone any repository

git clone 'https://github.com/mursalfk/mursalfk.git'

  • 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


This content originally appeared on DEV Community and was authored by Mursal Furqan


Print Share Comment Cite Upload Translate Updates
APA

Mursal Furqan | Sciencx (2022-01-22T06:04:57+00:00) Git Commands Every Dev MUST know. Retrieved from https://www.scien.cx/2022/01/22/git-commands-every-dev-must-know/

MLA
" » Git Commands Every Dev MUST know." Mursal Furqan | Sciencx - Saturday January 22, 2022, https://www.scien.cx/2022/01/22/git-commands-every-dev-must-know/
HARVARD
Mursal Furqan | Sciencx Saturday January 22, 2022 » Git Commands Every Dev MUST know., viewed ,<https://www.scien.cx/2022/01/22/git-commands-every-dev-must-know/>
VANCOUVER
Mursal Furqan | Sciencx - » Git Commands Every Dev MUST know. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/22/git-commands-every-dev-must-know/
CHICAGO
" » Git Commands Every Dev MUST know." Mursal Furqan | Sciencx - Accessed . https://www.scien.cx/2022/01/22/git-commands-every-dev-must-know/
IEEE
" » Git Commands Every Dev MUST know." Mursal Furqan | Sciencx [Online]. Available: https://www.scien.cx/2022/01/22/git-commands-every-dev-must-know/. [Accessed: ]
rf:citation
» Git Commands Every Dev MUST know | Mursal Furqan | Sciencx | https://www.scien.cx/2022/01/22/git-commands-every-dev-must-know/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.