Remove one merged branch from the master branch
My master branch has the following local branches that have been merged, but I would like to remove local_branch3
from master:
local_branch1
local_branch2
local_branch3
local_branch4
after removing local_branch3
from master, I would like it to remain a local branch (only removed from master).
I checked Steve Harman 's blog for the same issue, but this also deletes the local branch permanently.
Edit: to clarify what I meant, as I posted in one of the following comments:
I would like the master branch to revert the changes as a result of the local_branch3 merge, leaving local_branch3 untouched.
The reason is that I would like to keep the branch master
if I tune in local_branch3
.
source to share
If I read the question correctly, shirakia's answer (revert merge commit changes) is correct, it works as advertised and the OP should use it.
But it's worth noting what happens if further work on local3 makes all of this valid, and you naturally want to reapply the original work along with these later fixes.
Local 3 commits as this merge is now part of the merge commit history. Since the underlying content for any subsequent merges from local3 resides in the new merge base, this entire story is effectively marked as (indeed, it has been) applied correctly: any subsequent merge only sees the changes made since then. The checkout did not undo this part (in fact, it was the purpose of the checkout, so as not to remove this commit).
Another, arguably easier way of setting it, is the correct way to undo any commit you don't want to remove from your history is to revert it. This includes any subsequent decision to cancel the reversion.
source to share