Skip to content

Instantly share code, notes, and snippets.

@jgravois
Last active March 22, 2016 16:46
Show Gist options
  • Save jgravois/f3571b2e98657c07f54d to your computer and use it in GitHub Desktop.
Save jgravois/f3571b2e98657c07f54d to your computer and use it in GitHub Desktop.
get out of jail git commands

use these commands VERY carefully!

$ git checkout filename.txt

blows away whatever changes you've made to a tracked file and replaces the file with what was present in the most recent commit

$ git reset --hard HEAD

forcefully rewinds you to the most recent commit, blowing away all uncommitted changes you've made locally

$ git reset --hard f772f4 (sha)

same as above, but allows you to rewind to a specific named commit (via its SHA)

$ git push origin branch --force

allows you to rewrite history on a remote. you should never execute this command on a branch that anyone other than yourself is tracking.

$ git push upstream master

you have permission to do this, but we are trusting you to do your work in your own branch and submit Pull Requests instead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment