Skip to content

Instantly share code, notes, and snippets.

@mriddle
Created January 25, 2012 02:49
Show Gist options
  • Save mriddle/1674324 to your computer and use it in GitHub Desktop.
Save mriddle/1674324 to your computer and use it in GitHub Desktop.
[git foo] reverting multiple commits in one hit
# Below is the strat on reverting multiple commits while rolling forward rather than winding back
$ git reset --hard f7a4ffb0291f5fab47dd539a47e04bbd659e138
# Where the SHA is the known good version you want to be back at
$ git reset --soft @{1}
# Which brings you back to origin head with the changes off the past commits reversed
# eg
# [-console.log("Loosing")-]{+console.log("Winning")+}
# becomes
# [+console.log("Winning")+]{-console.log("Loosing")-}
$ git commit -m "I won"
$ git push
# It's probably worth mentioning that you can then apply the reverted commits one by one easily using
$ git cherry-pick f7a4b-SHA-YOU-WANT-APPLIED-d6e138
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment