Reputation: 46760
I had a branch that I merged into master. Then we've merged other things into master after that. So we now have this state in master
------------------------------
stuff added to master recently
------------------------------
my branch merged into master
------------------------------
old stuff in master
------------------------------
I want to remove my merge from master and leave all else intact so that I get the following state in master
------------------------------
stuff added to master recently
------------------------------
old stuff in master
------------------------------
How do I do that?
Upvotes: 3
Views: 63
Reputation: 1328702
You could do a rebase interactive on master
, and use that interactive rebase session to drop the commits you don't want anymore (git rebase -i
).
git checkout master
git rebase -i <SHA1 old stuff in master>
Note that it will change the master history, which would lead to a git push --force
if you already pushed master to a remote repo. And that could be inconvenient for others having already pulled from that same remote repo.
If you had already pushed master, then a git revert -m 1
would be easier to push as well: See "Undo a Git merge?". That will create a new commit (cancelling the merge one)
Upvotes: 2