G1-B1-G2-G3-G4-G5-G6-G7-B2-G8-G9
I have above commit already in master
.
What's the best way to revert B1 and B2 from above commit?
And re-pushed to master
.
Reset and cherry-pick seems quite a bit of jobs.
Just want to find a better and simple option to do this.
CodePudding user response:
The cleanest way would be to issue two git revert
commands:
git revert B1
git revert B2
That would create two new commits, negative images of B1, and B2, allowing you to do a simple git push (no force needed, no "history rewrite")
CodePudding user response:
If you want to keep the commits but revert their changes, see VonC's answer.
If you want to rewrite history and exterminate these commits as if they never existed, you can use an interactive rebase:
git rebase -i G1
Delete the lines for B1 and B2 in your text editor, save, exit, and they'll be removed from history. The usual caveats when rewriting history apply.