Skip to content

Instantly share code, notes, and snippets.

@BrunoGrandePhD
Last active August 18, 2016 14:38
Show Gist options
  • Save BrunoGrandePhD/8422c189c1f5028c2a44dcab86453e65 to your computer and use it in GitHub Desktop.
Save BrunoGrandePhD/8422c189c1f5028c2a44dcab86453e65 to your computer and use it in GitHub Desktop.
git branch new-master # Assumption: HEAD is pointing to the new commits
git checkout master
git branch before-revert
git revert --no-edit commit_X..master # Revert the commits you want to discard
git rebase -i before-revert # Optional: squash all commits except top one to create one revert commit
git checkout new-master
git rebase master
git checkout master
git merge new-master
git branch -D new-master before-revert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment