In my git workflow i have to merge a feature
branch into master
.
However while i am resolving merge conflicts, somebody has pushed a new commit to feature
and master
.
I have then to generate a new merge commit, based on new feature
and new master
. However 90 % of the merge conflicts are still the same.
So my question is. Can i save my progress from the first merge
, and apply it in the conflict phase of the new merge
?
+--------+ +--------+ +------------+
| | | | | |
| init +------> | master +-----------> | new master |
| | | | | |
+--------+ +--------+ +------------+
| | |
| +---------+ +-------------+
| | | | |
+---------> | feature +----------> | new feature |
| | | |
+---------+ +-------------+
| | ||
| | ||
| | +----------------+ || +-----------+
| +----> | | +---------> |
| | first merge | | | new merge |
+-----------> | +---------> |
+----------------+ +-----------+
A merge conflict is an event that occurs when Git is unable to automatically resolve differences in code between two commits. When all the changes in the code occur on different lines or in different files, Git will successfully merge commits without your help.
Git has a feature called rerere. It can be used at this situation. Enable rerere in config file and it just works. I think it is the right way to resolve this problem.
https://git-scm.com/blog/2010/03/08/rerere.html
https://git-scm.com/docs/git-rerere
To use this feature without enabling it in advance, the script https://github.com/git/git/blob/master/contrib/rerere-train.sh can help you.
Maybe there is a simple method to do it.
Merge new feature
to first merge
and then merge the result to new master
.
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