Frontend Quick Tips #18 Rerere - Conflict Hell Solution
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.
If the same conflict appears, git resolves it under the hood. Conflicts are invisible and you are happy!
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?
A few more commands can be foundhere.