Your Linux Data Center Experts
Sean's Git Cheatsheet
By Sean Reifschneider
Date March 2, 2013
Changes in Local Copy
- Shows changed files or files not under version control.
- Goes hand-in-hand with .gitignore so that uninteresting files aren't
listed in "git status" output.
- I always run it before a "git commit -a" to be sure of what I'm
Tagging Code for Release
git tag -s release-1.00
- -s option signs release.
- "release-1.00" is just a string, but I always make mine "release-"
and the version number.
Un-rm or Revert Local Changes
git checkout HEAD -- $FILENAME
- If you accidentally removed a file with "git rm" or the shell
- If you have made uncommitted changes and want to revert back to the
Reverting to Previous Upstream Commit
I used this when I had pushed up a new change to github and after
suggestions by a reviewer I decided to completely undo it and start
git push --force origin OLD_COMMIT_ID:master
git reset --hard origin/master
Merging Upstream Code
# one-time setup
git remote add upstream $UPSTREAM_GIT_URL
# to later pull in changes from upstream
git fetch upstream
git merge upstream/master
comments powered by
- Used when you have your own fork with local changes, but want to
continue to include new code from upstream.