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
- 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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.