Git Deep Dive: Mastering rerere

No, It’s Not a Typo: Let’s Talk About git rerere (Reuse Recorded Resolution)

git rerere helps Git remember how you resolved a conflict previously, and automatically reuses that resolution when the same conflict occurs again. This can be a huge time-sa…


This content originally appeared on DEV Community and was authored by Louis Liu

No, It's Not a Typo: Let's Talk About git rerere (Reuse Recorded Resolution)

git rerere helps Git remember how you resolved a conflict previously, and automatically reuses that resolution when the same conflict occurs again. This can be a huge time-saver with recurring merge conflicts.

How to enabled it

Globally:

git config --global rerere.enabled true

Per project:

git config rerere.enabled true

Check status:

git config --get rerere.enabled

Example

I'm updating hello.txt on main and feature/earth branch.

Hello!

On main branch:

Hello World!

On feature/earth branch:

Hello Earth!

Now, if we try to merge feature/earth into main, we’ll get a conflict:

git checkout main
git merge feature/earth

Conflict:

<<<<<<< HEAD
Hello World!
=======
Hello Earth!
>>>>>>> feature/earth

We edit the file to:

Hello Universe!

Then stage and commit:

git add hello.txt
git commit

Git will record the resolution:

Recorded resolution for 'hello.txt'.
[main 7fd7eda] Merge branch 'feature/earth'

Next time Git encounters the same conflict, it will automatically reuse the previous resolution:

git merge feature/earth

You got:

Auto-merging hello.txt
CONFLICT (content): Merge conflict in hello.txt
Resolved 'hello.txt' using previous resolution.
Automatic merge failed; fix conflicts and then commit the result.

Useful commands

# Manually trigger rerere
git rerere
# Forget a recored resolution
git rerere forget <file>
# Check the rerere cache
ls .git/rr-cache/
cat .git/rr-cache/<conflict-id>/preimage

If you don’t want Git to auto-resolve using rerere, you can reset the file:

git checkout --conflict=merge <file>

Advanced

When Git detects a conflict during a merge or rebase, it generates a hash key based on the conflicting content — this becomes the conflict-id.

Git then stores:

  • The preimage (conflicted content)
  • The postimage (your resolved version)

These are saved under .git/rr-cache/.

File Structure:

.git/
└── rr-cache/
    ├── <conflict-id>/
    │   ├── preimage      # The file before conflict resolution
    │   ├── postimage     # The file after conflict resolution
    │   └── thisimage     # Temporary file used during auto-resolution

Important Notes

  • The conflict-id is not a Git object, even though it looks like one.
  • It’s stored locally only — it won’t be pushed to the remote.
  • If you delete .git/rr-cache, the resolution is gone forever.

Summary

git rerere is a powerful but often overlooked tools. It can save you a lot of time when dealing with recurring merge conflicts.


This content originally appeared on DEV Community and was authored by Louis Liu


Print Share Comment Cite Upload Translate Updates
APA

Louis Liu | Sciencx (2025-11-12T18:00:00+00:00) Git Deep Dive: Mastering rerere. Retrieved from https://www.scien.cx/2025/11/12/git-deep-dive-mastering-rerere/

MLA
" » Git Deep Dive: Mastering rerere." Louis Liu | Sciencx - Wednesday November 12, 2025, https://www.scien.cx/2025/11/12/git-deep-dive-mastering-rerere/
HARVARD
Louis Liu | Sciencx Wednesday November 12, 2025 » Git Deep Dive: Mastering rerere., viewed ,<https://www.scien.cx/2025/11/12/git-deep-dive-mastering-rerere/>
VANCOUVER
Louis Liu | Sciencx - » Git Deep Dive: Mastering rerere. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/11/12/git-deep-dive-mastering-rerere/
CHICAGO
" » Git Deep Dive: Mastering rerere." Louis Liu | Sciencx - Accessed . https://www.scien.cx/2025/11/12/git-deep-dive-mastering-rerere/
IEEE
" » Git Deep Dive: Mastering rerere." Louis Liu | Sciencx [Online]. Available: https://www.scien.cx/2025/11/12/git-deep-dive-mastering-rerere/. [Accessed: ]
rf:citation
» Git Deep Dive: Mastering rerere | Louis Liu | Sciencx | https://www.scien.cx/2025/11/12/git-deep-dive-mastering-rerere/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.