ahg
===== Create repository
git-init - create repository in current dir
===== Concepts
index - changes that have been "git-add"ed but not committed
workspace - current dir contents
head - most recent commit on current branch
HEAD - symbol meaning "tip of current branch"
If HEAD does not point to tip of branch, then you must create a new branch to
do a checkin.
<b> - a branch
<c> - a commit (sha1 hash)
<t> - a tag
<tr> - can be a commit, a tag, or a branch (refers to tip commit of branch)
<f> - a filename
===== STASH
git-stash save <msg> - save current workspace & index, and then empty them
git-stash list - list stashes
git-stash apply - bring back most recent stash
git-stash apply <name> - bring back named stash (name from git-stash list)
===== BRANCHES
git-checkout <tr> - sync working dir to <tr> and set HEAD to <tr>
git-checkout -f <tr> - force (discard all local changes)
git-checkout -b <b> <tr> - same as:
git-checkout <tr>
git-branch <b>
git-branch - list all branches
git-branch <b> - create <branch> pointing at current head
git-checkout <b> <f> - get <f> from <b> and put in index & workspace
git-checkout -f <b> <f> - force (overwrite local changes in index & workspace)
===== REVERT
git-reset - revert index but leave workspace as-is
git-reset --hard - revert all uncommitted changes & merges
git-checkout -f HEAD <f> - revert file <f> (discard workspace & index changes)
DANGEROUS: git-reset --hard HEAD^ - obliterate most recent commit
(use only right after commit)
===== DIFF & STATUS
git-status - show which files changed in index and workspace
git-diff - diff index vs workspace
git-diff --cached - diff HEAD vs index
git-diff HEAD - diff HEAD vs workspace
git-diff <tr1> <tr2> - diff <tr1> vs <tr2>
git-diff -- <f> - diff just file <f> (same options as above before --)
mygitdiff - use gdiff (same options as above)
git-log - show history of a commit
git-reflog - show history of a branch (HEAD by default)
===== BASIC STUFF
git-add . - add ALL changes in workspace (recursive) to index
git-add <file> - add current version of <file> to index
git-add <dir> - add current version of <dir>/... to index
git-rm <file> - remove <file> from workspace & index
git-status - show files changed in index and workspace
git-commit - create commit from current index