This post shares some useful commands which are used commonly.
For making some configuration level changes following command is used
git config --// parameters check using --help
It include commands by which you create a repository or want to use already created
It is used to create git repository in some directory. Execute following command in directory.
It is used to download a repository source code from remote into your local. For this following command is used.
If you want to see changes done on source code. It shows both type of files index and non-indexed. Indexed files are basically those which are under version control. For this following command is used.
If you want to commit your file, first you have to add them or stage them. For this following command is used.
git add * // to add all in one go git add < file or directory>
When you want to commit changes to local repository. For this following command is used.
git commit -m "Commit Message" // it will just commit git commit -a -m "Commit Message" // it will perform add then commit -a will add only tracked files
When you want to see changes or difference you have from repository code which is basically known as HEAD. For this following command is used.
git diff // diff with HEAD git diff // diff with specific only
List of branches
When you want to see all branches following command is used.
git branch git branch -a // will show remote branches also
Checkout a branch
It is used when you want to move to another branch or creating new branch from current.
Note : First you have commit your changes on existing branch or stash them.
git checkout git checkout -b
Merge two branches
It is used when you want to combine source code of two branches or committed code. For this following command is used.
git merge <Branch Name>
It is used when you want to delete a branch from local and remote.
git branch <Branch Name> git branch -D <Branch Name
When you want to get all information from remote to your local such as new branches and changes.
When you want to get latest changes from remote following command is used.
When you want to push your changes to remote
Advance Level Commands
It is used when you want to integrate change of a particular commit into your current commit.
This will revert all commits since the current branch diverged from upstream, and then re-applies them one-by-one on top of changes from the HEAD of upstream.
git rebase <upstream>
Clean Up Commands
Remove & Moving of File
git rm <file> git mv <file>
git reset git reset remote | branch
It remove files which are not on version control.