Why do I have to resolve the same "git rebase" conflict over and over?

GitGit RebaseGit Merge-Conflict

Git Problem Overview


When I do git rebase branch1 in my branch1-local I get conflicts. I solve the conflict, do git add <conflicted-add> and then do git rebase --continue as git asks me to do. After that a new commit is applied. A new conflict shows up. But is the same conflict again in the same file. I do it again, git add, the git rebase --continue, and then it all repeats again until I repeat this for each commit being rebased on.

Why rebase is having me redo the same conflict resolution over and over again?

Git Solutions


Solution 1 - Git

What you want is git rerere which records conflict resolutions for you. The best introduction to this I have seen is now part of the Git Book, Tools chapter. In practice when you perform a rebase, you will end up stopping as before but you only have to check the merge conflict remains resolved then git add it and continue.

Solution 2 - Git

You should not be getting the same conflict over and over. Rerere will not help you here. It simply means that the codebase that you are trying to replay commits over is so different that each commit needs your help to adjust it. This is one of the reasons to favour merge over rebase. In my opinion, rebase should be used only if necessary and not part of your regular workflow. Rerere will help a lot more in a merge/reset type workflow. Here is my workflow that avoids rebasing: http://dymitruk.com/blog/2012/02/05/branch-per-feature/

One way to ease some of the pain is to use a smart merging program like Beyond Compare. It is syntax aware and will solve quite a few conflicts that Git will (rightfully) refuse to do for you. Many times, these tools, when invoked, won't even open their UI, solve the issue and allow your git mergetool command to continue on to the next conflict. Remember to set "trust mergetool exit code" to true.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlurscherView Question on Stackoverflow
Solution 1 - GitpatthoytsView Answer on Stackoverflow
Solution 2 - GitAdam DymitrukView Answer on Stackoverflow