git init <directory>
git init --bare <directory>
Bare flag creates a repository without a working directory in it. Used for creating a repository on a server.
git clone <repo> [<directory>]
git branch
git branch <name>
git branch -d <name>
git branch -D <name>
git push <remote> <branch-name>
Assigns the association b/w a local and a remote branch and doesn’t ask which branch to push/pull to in future.
git push -u <remote> <branch-name>
e.g.
git push origin name
git push origin --delete <branch-name>
git branch -m <name>
git checkout <branch>
Following command is needed if a file/dir exists with the same name as branch:
git checkout <branch> --
git checkout -b <branch>
If you have local changes in your working dir, these will come as local changes in the new branch created. This command is equivalent to following two commands:
git branch <name>
git checkout <name>
git merge <branch-name>
git push -u origin <branch-name>
git config --global diff.external /path/to/diff/tool
git config --global --unset diff.external
git config --global core.editor "vim"
git config --global user.email "xyz@xyz.com"
git commit --amend
git remote -v
git remote add origin sri.cse.iitd.ernet.in:repo/notes
git reset
git reset --hard
git submodule status
© 2018-19 Manjeet Dahiya