from http://progit.org/book/
add command tracks and stages an untracked file, and stages a tracked and modified file, overwriting any staged copy.diff shows what you’ve changed but not yet staged; adding --staged shows what you’ve staged and will commit next.diff compares files in the working directory with their staged copies, not those in the repository.--cached to rm only removes a file from staging, so it is untracked; omitting it also removes the file from the working directory.--stat option for log shows summarized diff stats for files; --graph shows branch and merge history and is useful with --pretty.log to specific files and paths, append them to the command, preceded by a double dash.commit with --append to overwrite your last commit; without adding any files, you will simply overwrite your commit message.fetch command doesn’t merge new data with your own; git pull will try to automatically merge, and works if you’ve run clone.git push origin master, origin is the server to push to, and master is the branch to push.tag immediately after a commit, specify the commit checksum or its unique prefix at the end of the command.git branch command creates a new brach, but the HEAD pointer does not refer to the new branch until you use checkout.checkout command with the -b option.stash and commit amending can help.git branch --merged; branches listed by --no-merged cannot be deleted yet.fetch retrieves new remote branches as read-only pointers prefixed with origin/, which you manually merge to make editable.git pull and git push work without arguments.rebase replays changes from one line of work onto another, so the log will show a linear history instead of a parallel one.rebase commits that you’e pushed to a public repository, as others will base work on commits that you’ve rebased.--abbrev-commit to the git log command will use unique SHA-1 prefixes in the output.^{n} a the end of a reference refers to its nth parent; using ~{n} traverses n parents up the ancestry tree.git add in interactive mode with -i and selecting 5 or p allows staging parts of files; when done, use git commit.stash command takes the dirty state of your working directory and saves it on a stack of unfinished changes you can reapply later.stash apply with the --index option.stash branch branches from the commit you were on when you stashed your work, then applies and drops the stash.rebase, so don’t amend your last commit if you’ve already pushed it.rebase in interactive mode to rebase them onto the HEAD they were originally based.filter-branch command allows rewriting your history easily, but don’t use it if other people have based work off those commits.-C to blame tries to figure out where snippets of code within the file came from if they were copied from elsewhere.bisect, don’t forget to run bisect reset to reset your HEAD to where you started, or you’ll end up in a weird state.diff between the branch of a subproject and the superproject it’s merged into, you must run diff-tree instead of diff.HEAD isn’t another SHA-1 value, but a reference name.refs/heads on the server are written to refs/remotes/origin locally; branches can be qualified with the latter.HEAD, so branching from a reflog entry can surface them again.