One Tip a Week: git’s rerere

This week’s tip of the week is git rerere. It stands for “reuse recorded resolution,” and if you’ve ever been knee-deep in a painful rebase fixing the same conflict over and over again, this one’s for you.

Here’s what it does: when you resolve a merge conflict, Git can remember how you fixed it. Then, if that same conflict shows up again later, Git can automatically apply your previous resolution. No more fixing the same line in the same file across ten commits.

To turn it on globally, run:

git config --global rerere.enabled true

From then on, Git will quietly record how you resolve conflicts. The next time you hit the same one, you’ll see something like:

Resolved 'best-file.txt' using previous resolution.

You can also inspect what rerere is tracking with:

git rerere status
git rerere diff

And if you ever want to clean up old remembered resolutions, just run:

git rerere gc

It’s a simple switch that can turn a frustrating rebase into a smooth one. Once you’ve used it, you’ll wonder how you ever lived without it. Shoutout to Dillon Mulroy for putting this on my radar.

That’s it! Short and sweet. Until the next one!