Avoid to solve multiple times the same conflict on rebase with GIT

TechupBusiness
2 min readFeb 15, 2019

--

This unknown configuration allows to record and reuse previous conflict solutions. It’s a time saver when working with rebase and merge conflicts in GIT.

Photo by vision webagency on Unsplash (Partner of ost.com)

tl;dr: Execute git config --global rerere.enabled 1 to avoid repetitive manual merging.

So what is doing git rerere exactly? It stands for reuse recorded resolution and is a configuration parameter that enables git to record your merge/rebase resolution of all conflicts and to automatically apply these records if the same conflict appears again.

But how can the same conflict happens more than once? When you just use merge commits this may occur just sporadically, when you create a merge commit and then revert it for some reasons.

But if you use rebase (highly recommended!) to get rid of all conflicts before merging your branches into master, you will sometimes run into the problem, that you need to solve the same conflict again and again. But why?

This is becausegit rebase merges commit after commit of your source branch on top of the target branch. Whilegit merge is doing internally two “commits”, one with the entire set of changes of all commits as one single operation (no squashing), the other is the merge commit to solve the difference of the first operation set to the target branch.

You could also manually execute git rerere every time after resolving a conflict and before doing the commit. But the easier way is to run and forget:

> git config --global rerere.enabled 1

Happy rebasing!

--

--

TechupBusiness
TechupBusiness

Written by TechupBusiness

Business, Technology, Investments

No responses yet