Skip to content

Instantly share code, notes, and snippets.

@guillermoroblesjr
Last active October 28, 2015 14:59
Show Gist options
  • Save guillermoroblesjr/9b5892d8d8d35abb08c5 to your computer and use it in GitHub Desktop.
Save guillermoroblesjr/9b5892d8d8d35abb08c5 to your computer and use it in GitHub Desktop.
Git checkout/revert to an older hash on a new branch
# directory goes back to the hash, ALL changes AFTER hash are discarded.
# you can always merge in a different branch to update later changes.
git checkout -b <temp-branch-name> <myHashGoesHere>
# OR
# create a new branch
git checkout -b <temp-branch-name>
# reverts all files that were originally part of this hash back to their
# state at the time of the hash.
# any files that were added after this hash are not unaffected and stay
# the same.
git checkout <hash> .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment