When I pull master into a branch, it may succeed, or it may conflict, depending on activity on both branches since they separated.
When it conflicts, I will go through and manually resolve the conflict, eg using git mergetool, and then I'll commit the merge (eg git commit -m "Merge in latest master"). That gives a commit, merging two different commits which conflicted. I've got this so far. However this can be a lot of work to resolve that.
Shortly after on another feature branch, pulling master into that feature branch, I'll get the exact same conflict. Exact same files, exact same changes on both branches. How can I re-use the effort expanded to merge those two commits again?
Eg, I'd like a "git apply-existing-merge" option, as used below:
git checkout JOB-12345
git pull origin master
CONFLICT (content): file1
CONFLICT (content): file2
CONFLICT (content): file3
(does much work to fix it)
git commit -m "Massive complex merge of upstream code"
[JOB-12345 93697088ad0] Massive complex merge of upstream code
... Later that day
git checkout JOB-12346
git pull origin master
CONFLICT (content): file1
CONFLICT (content): file2
CONFLICT (content): file3
git apply-existing-merge 93697088ad0
[JOB-12346 93697088ad0] Merge in the latest upstream changes.
Attempting to graph it
Master : X-----1--X----X
\ \ \
Feature 1: X-2-X-4--X-A \
\ \
Feature 2: X-3-------X-B
1 and 2 conflict. So pulling 1 into (2,4) creates the exact same conflict that pulling 1 into (2, 3)
How can I merge 1 and 2 in such a way that I can do it once, but apply it twice. (And without corrupting the feature branches, I need to ensure A only contains (1, 2, 4), and B only contains (1, 2, 3)?
I've tried messing around with cherry-pick and creating and applying patches, however I can't get anythiing working. I expect it must be possible.