Rebase upstream changes with non-trivial merge commits submitted locally

As a developer on php-src I recently found myself in the following situation:

ABC o---o---o version1 \ o---o-----o---o master xy DE o---o---o upstream/master xyz 

So, when I do git push --dry-run upstream master version1 , I get typical:

 ! [rejected] master -> master (fetch first) 

My natural answer is to reload a damaged branch and save commits:

 git fetch upstream git rebase -p upstream/master 

It is important to note that the initial merge merge was not trivial because there are so many changes between the version branch and the master; he is making efforts to resolve such a merger.

Performing the above rewrite operation causes a merge conflict, and I must resolve it again; it’s almost the same as what I’ve already done.

Is there a better way to do this? Or did I forget the obvious reinstallation option?

+6
source share
1 answer

Ideally, you "reuse recorded resolution" with rerere :

In the process of using relatively durable topic branches, the developer sometimes needs to resolve the same conflicts over and over until the topic branches are merged into a “release” branch or sent and received upstream).

This command helps the developer in this process to record conflicting auto attendant results and the corresponding hand resolution results at the initial manual merge and apply previously recorded hand permissions to their corresponding auto attendant results.

Unfortunately, this feature must be enabled before you merge first:

Note. You need to set the rerere.enabled configuration variable to enable this command.

As far as I know, there is no shortcut to do something similar after the fact. I recommend enabling rerere globally and then re-merging:

 git config --global rerere.enabled true 

In the future, this option can save a lot of time!

+3
source

Source: https://habr.com/ru/post/974666/


All Articles