Reputation: 1177
Given the following git workflow:
According to the documentation solving this conflict implies that release-branch-1.x.x (which contains fb1 code) be merged in fb2 locally, decide what to keep (solve conflict), then fb2 be pushed to remote to update the pull-request.
This solves the conflict all right, but adds all the work on release-branch-1.x.x to fb2 which is something I would like to avoid. Say I want to revert the fb1 merge commit, the fb1 code will still be on the release branch because it was introduced by fb2.
Any thoughts on how can this be avoided?
Upvotes: 0
Views: 71
Reputation: 4253
In most workflows, the owner of each feature branch is responsible for keeping their branch up to date with whatever the "official" line of code is (To be as generic as possible, I'll call the integration branch master, though it can be develop, release, or other name in various workflows). So the full sequence for your scenario would look like this:
Git uses the most recent common ancestor of two commits when merging, not the original point where the code diverged. Even if there were no conflicts, when the changes from master including fb1, are integrated into fb2, the common ancestor between those two branches would be a point on master containing initial + fb1, if fb1 was subsequently removed from master, git would see those changes had occurred on the master branch and the resulting merge would not contain those changes.
You can think of a merge algebraically, where m = merge
, b = base
, l = left
, r = right
, f = feature
and i = initial
m = b + diff(b,l) + diff(b,r)
m = (i + f1) + diff((i + f1), (i)) + diff((i + f1), (i + f1 + f2))
m = (i + f1) + (-f1) + (f2)
m = i + (f1 + -f1) + (f2)
m = i + f2
Upvotes: 2