Skip to content

Instantly share code, notes, and snippets.

@maml
Created March 30, 2013 00:55
Show Gist options
  • Save maml/5274754 to your computer and use it in GitHub Desktop.
Save maml/5274754 to your computer and use it in GitHub Desktop.
If you want to commit on top of the current HEAD with the exact state at a different commit, undoing all the intermediate commits, then you can use reset to create the correct state of the index to make the commit.
# reset the index to the desired tree
git reset --hard 56e05fced (the sha you `want to go to there` to)
# move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}
git commit -m "Revert to 56e05fced"
@maml
Copy link
Author

maml commented Mar 30, 2013

as seen on http://stackoverflow.com/questions/1895059/revert-to-a-commit-by-sha-hash - anwser provided by Charles Bailey

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