As a developer on php-src I recently find myself in the following situation:
A B C
o---o---o version1
\
o---o-----o---o master
x y D E
o---o---o upstream/master
x y z
So when I do git push --dry-run upstream master version1
I get the typical:
! [rejected] master -> master (fetch first)
My natural response is to rebase the affected branch and preserve merge commits:
git fetch upstream
git rebase -p upstream/master
It's important to note that the original merge commit wasn't trivial, because there are so many changes between the version branch and the master; it takes an effort to resolve such a merge.
Doing the above rebase operation causes a merge conflict and I have to resolve it again; this is almost exactly the same job that I had already done.
Is there a better way to do this? Or did I forget an obvious rebase option?
Ideally you would "reuse the recorded resolution" with rerere
:
In a workflow employing relatively long lived topic branches, the developer sometimes needs to resolve the same conflicts over and over again until the topic branches are done either merged to the "release" branch, or sent out and accepted upstream).
This command assists the developer in this process by recording conflicted automerge results and corresponding hand resolve results on the initial manual merge, and applying previously recorded hand resolutions to their corresponding automerge results.
Unfortunately, this feature must be enabled before you first do the merge:
Note: You need to set the configuration variable rerere.enabled in order to enable this command.
As far as I know, there is no shortcut to do something like this after the fact. I recommend enabling rerere
globally and then redoing the merge:
git config --global rerere.enabled true
In the future, this setting could save you lots of time!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With