Skip to content

Instantly share code, notes, and snippets.

@jzpeepz
Last active February 24, 2020 20:53
Show Gist options
  • Save jzpeepz/be38576bceaf1268b92deb10751ab0b4 to your computer and use it in GitHub Desktop.
Save jzpeepz/be38576bceaf1268b92deb10751ab0b4 to your computer and use it in GitHub Desktop.
Revert to the specific revision using git reset

Revert to the specific revision using git reset

The solution comes from the Revert to a commit by a SHA hash in Git? question. Here we first hard reset the state of the repository to some previous revision and then soft reset back to current state. The soft reset will keep file modifications, so it will bring old state back on top of the current state:

Careful, reset —hard will remove non-commited changes

$ git reset —hard 0682c06  # Use the SHA1 of the revision you want to revert to HEAD is now at 0682c06 G3
$ git reset —soft HEAD@{1}
$ git commit -m “Reverting to the state of the project at 0682c06”
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment