September 2nd, 2008
Git Cheatsheet
It’s small, fast, and github is rad. So I am trying to learn it.
# Setup git config --global --list git config --global user.name "Ken-ichi" git config --global user.email "fortinbras@norway.net" # The colors, children. Mm-hey git config --global color.diff auto git config --global color.status auto git config --global color.branch auto # Getting Info git remote -v # Display the remote repository URL git log # duh git show COMMIT # equivalent of svn log -r REV_NUM, but with diffs # Committing git add . git commit -a # Amending git commit -a --amend # Reverting git reset --hard HEAD # revert everything to HEAD git checkout path/to/file # reset a single file # Checking out previous states git checkout COMMIT git checkout master # to get back # Stashing git stash # stash changes on this branch so you can switch and work on something else git stash pop # bring back the stashed changes # Pushing to another repos # could be local like /path/to/somewhere # or ssh://me@there.net/path/to/repos git push path/to/repos git push origin master # if you cloned from a remote named origin # to switch origins git remote rm origin git remote add origin 'path/to/a/bare/repo' # note that when sharing a repo with others, you will all want to push/pull from a *bare* repo made with git clone --bare path/to/repo # See http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#public-repositories # Branching and merging git branch new_branch && git checkout new_branch # make a new branch and switch to it git checkout -b new_branch # same as above git merge other_branch git mergetool -t opendiff # resolve conflicts in a merge with FileMerge