How to avoid repeated merge conflicts?

I would recommend all developers to set up this globally; you will love it and won't even remember it.

As every developer knows, fixing merge conflicts can be tedious, but repeatedly solving the same conflict (e.g., in long-running feature branches) is annoying. If you’ve suffered from this, you’ll be happy to learn about the underused reuse recorded resolution feature. Add it to your global config to enable it for all projects:

git config --global rerere.enabled true

Alternatively, you can enable it on a per-project basis by manually creating the directory .git/rr-cache.

This sure isn’t a feature for everyone, but it can be a real-time saver for people who need it. Imagine your team is working on various feature branches at the same time. Now you want to merge all of them into one testable pre-release branch. As expected, there are several merge conflicts, which you resolve. Unfortunately, it turns out that one of the branches isn’t quite there yet, so you decide to un-merge it again. Several days (or weeks) later, when the branch is finally ready, you merge it again, but thanks to the recorded resolutions, you won’t have to resolve the same merge conflicts again.

The man page (man git-rerere) has more information on further use cases and commands (git rerere status, git rerere diff, etc.).

Originally Posted On: (citizen428)

Subscribe to GIT.WTF!?!

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]