Reputation: 55934
Imagine this scenario:
master: M
release-candidate: \ A--B'--C'
feature-A: \-A-/ / /
feature-B: \-B--/ /
feature-C: \--C---/
The release-candidate was created by using the following commands:
git co master
git co -b release-candidate
git merge feature-A (FAST FORWARD)
git merge feature-B (REGULAR MERGE)
git merge feature-C (REGULAR MERGE)
Let's say during our pre-release testing we find a problem with feature A. How do we undo the changes introduced by the fast-forward merge of this feature branch into the release-candidate branch?
We could potentially reset release-candidate back to its master state and start merging all the valid features again but this would mean repeating a lot of merge conflict resolution and introduces the possibility for error.
Note also that I've only shown a single commit on each of the feature branches but a solution should work in the case where there is more than one commit to undo.
Upvotes: 3
Views: 1770
Reputation: 38734
As you do not want to rewrite published history, git revert
is your friend.
In this case:
git revert M..A -n
git commit -m "revert feature-A"
if you want the revert in one commit, or
git revert M..A
if you want to have one revert commit per original commit in reversed order.
Upvotes: 4