Frontend Quick Tips #18 Rerere - Conflict Hell Solution

Photo of Bernard Klatka

Bernard Klatka

Updated Jan 9, 2023 • 3 min read
building

No one likes those big articles - that’s why we’re creating Quick Tips - short tips to change your developer's life from the moment you read them.

Those may be some patterns explained in JS code on real-life examples or some techniques for better code.

Problem

Haven’t you ever struggled with resolving the same conflicts one by one while updating a week-old feature branch? Rebasing 17 new commits from base, resolving conflicts for 10 minutes, just so you could resolve them again in an identical way after a small merge came into the base?

Solution

As git documentation states - a bit of a hidden solution.

How to solve it?

git rerere is what you need here. It stands for reuse recorded resolution and is easy to use. All you have to do is configure it with git config —global rerere.enabled true (the -global flag is optional).

What next?

From now on git starts recording your work. It takes the file path, the specific conflicted lines and the way you resolved them.

text

text
If the same conflict appears, git resolves it under the hood. Conflicts are invisible and you are happy!

text

What if I made a mistake?

git forget <filepath> deletes the resolving pattern for a specified file, so you can start your journey from the beginning.

Don’t stop now!

If you are not using rebase at all, it’s a great opportunity to give it a try. Combining git rerere with git rebase can not only make your work more pleasant, but also clean your history. Who doesn’t like a simple looking tree?

how to resolve a pattern for a specific file
A few more commands can be found here.

Photo of Bernard Klatka

More posts by this author

Bernard Klatka

Codestories Newsletter  Check what has recently been hot in European Tech.   Subscribe now

We're Netguru!

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency
Let's talk business!

Trusted by: