Usage: in your ~/.bash_profile, include these two lines:
export CHEATS=~/path/to/cheats
. $CHEATS/load
branch | |
git branch --track release_003 origin/release_003 # create local branch which tracks remote branch | |
git branch -a -v # list branches | |
git branch -d deadbranch # delete branch | |
checkout: | |
git checkout -b mybranch # creates 'mybranch' from current state | |
git checkout mybranch # switches to mybranch | |
revert | |
git reset --hard | |
git checkout app/views/nodes/edit.rhtml # revert to the version of this file in the repo | |
git reset 6be3e0dee6f72a1e1bfacadf7e0c34a724954286 | |
merge | |
git merge origin/master | |
git cherry-pick e00fd03 # apply a single commit | |
git add script/deploy # removes conflicting state on file, like "svn resolved" | |
clean | |
git clean -f # remove untracked files, except those ignored by .gitignore | |
stash | |
git stash # stashes changes and does 'git reset --hard' | |
git stash apply # applies stashed changes (normally to another branch) | |
diff | |
git diff origin/mybranch # diff local copy against this branch # note that --unified=<number of lines of context around diff> | |
commit: | |
git commit -a -m "oh so good" # -a will include new files not yet 'git added' as well as modified files" | |
add: | |
git add * # add all files and dirs | |
git add -i # interactively add files | |
tag | |
git tag release_1 # makes a "lightweight tag" | |
git tag -a -m "yay!" rel_1 # makes a "tag object" -- which can be git described | |
git tag -l # list tags | |
git tag -d release_1 # delete tag | |
git push --tags | |
alias gh='more $CHEATS/git' |