Although there are enough resources on the web about Git, I will keep this one for my own reference.
http://cheat.errtheblog.com/s/git
- index: staging area (Imagine you are loading sand into the truck with bucket. Well, the bucket is like index :))
- <sha1>: sha1 hash of commit
- <file>: type the path to the file in question (path/to/file.ext)
git log --diff-filter=D --summary
git checkout <sha1>^ <file>
git show <sha1>^:<file>
git log -p <file>
git cherry <upstream_branch> <new_branch>
git log <upstream_branch>..<new_branch>
git log --name-only
git log --name-status
git log --stat
git describe --exact-match --abbrev=0
git describe --abbrev=0 --tags
git add --patch <file>
- y: stage this chunk
- n: do not stage this chunk
- s: split this chunk into smaller chunks
- e: edit this chunk
git checkout -b <branch_name>
or
git branch <branch_name>
git checkout <branch_name>
git branch (-d | -D) <branch_name>
cherry-pick A..B # Git 1.7.2+, commit A should be older than B
Check out git reset for great explanation and examples.
git reset --hard
Check out git reset for great explanation and examples.
git reset --merge ORIG_HEAD
git revert <sha1>
git checkout <sha1>^ -- <file>
git checkout -b <branch_name>
git push origin <branch_name>
git pull origin <branch_name> # without tracking
git checkout --track -b <branch_name> origin/<branch_name> # with tracking
git branch --set-upstream <branch_name> origin/<branch_name>
git push origin :heads/<branch_name>
or
git push origin :<branch_name>
git remote prune origin
git remote set-url origin http://new-example.com/repo.git
git submodule foreach 'git checkout master && git pull origin master'
Edit the .gitmodules file, then run:
git submodule sync
- remove the submodule's entry in the .gitmodules file
- remove the submodule's entry in the .git/config
- run
git rm –cached path/to/module
- without a trailing slash! - remove the submodule from the filesystem, run
rm -rf path/to/module/
- commit changes