Export a single snapshot to a ZIP archive called <file>
git archive master --format=zip --output=../website-12-10-2012.zip
For Unix users
git archive master --format=tar --output=../website-12-10-2012.tar
Export an entire branch, complete with history, to the specified file
git bundle create <file> <branch-name>
Re-create a project from a bundled repository and checkout <branch‑name>
git clone repo.bundle <repo-dir> -b <branch-name>
Temporarily stash changes to create a clean working directory
git stash
Re-apply stashed changes to the working directory
git stash apply
View the difference between two commits
git diff <commit-id>..<commit-id>
View the difference between the working directory and the staging area
git diff
View the difference between the staging area and the most recent commit
git diff --cached
Unstage a file, but don’t alter the working directory or move the current branch
git reset HEAD <file>
Revert an individual file to match the specified commit without switching branches
git checkout <commit-id> <file>
Create a shortcut for a command and store it in the global configuration file
git config --global alias.<alias-name> <git-command><git-command>
Display the specified object, where <type> is one of commit , tree , blob , or tag
git cat-file <type> <object-id>
Output the type of the specified object
git cat-file -t <object-id>
Display a pretty version of the specified tree object
git ls-tree <tree-id>
Perform a garbage collection on the object database
git gc
Stage the specified file, using the optional --add flag to denote a new untracked file
git update-index [--add] <file>
Generate a tree from the index and store it in the object database. Returns the ID of the new tree object
git write-tree
Create a new commit object from the given tree object and parent commit. Returns the ID of the new commit object
git commit-tree <tree-id> -p <parent-id>
Tips