Q: `git rerere` is enabled in your config. What does it do, and in what workflows does it save the most time?
rerere stands for "reuse recorded resolution." When enabled (git config --global rerere.enabled true), Git silently records how you resolved each merge conflict.
Want to master this scenario in a live sandbox? KodeKloud's Advanced Git Workflows, Rebase & Interactive Diagnostics covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "During a major release branch cut, we encountered this exact scenario and used Git internals to recover cleanly. The interviewer is testing: Understanding of rerere (reuse recorded resolution) and its niche but powerful use case.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Initial Diagnostics & Root Cause Analysis
rerere stands for "reuse recorded resolution." When enabled (git config --global rerere.enabled true), Git silently records how you resolved each merge conflict. If the *exact same* conflict appears again later, Git applies the same resolution automatically.
- You hit a conflict during merge or rebase and manually resolve it.
- Git records the conflict (before) and resolution (after) in
.git/rr-cache/. - Next time the same conflict appears (same pre-image), Git auto-applies your recorded resolution. You still need to
git addand commit, but the file is already correctly resolved. - Long-lived feature branches that you repeatedly rebase onto
main. Each rebase replays all commits, and the same conflicts keep appearing. With rerere, you resolve each conflict once; subsequent rebases are automatic. - Topic branch workflows where you test-merge branches into an integration branch, then discard the merge and re-merge later for the real release. Without rerere, you re-resolve every conflict.
Remediation & Permanent Safeguards
How it works: Where it shines: Caveats:
- Cherry-pick-heavy workflows (backporting fixes across release branches) where similar conflicts recur.
- The cache is local — not shared across clones. Each developer's rerere database is separate.
- If you resolve a conflict incorrectly, rerere will faithfully re-apply the wrong resolution. Use
git rerere forgetto clear a bad recording. git rerere gccleans up old recordings (default: unresolved conflicts older than 15 days, resolved ones older than 60 days).
- You hit a conflict during merge or rebase and manually resolve it.
- Git records the conflict (before) and resolution (after) in .git/rr-cache/.
- Next time the same conflict appears (same pre-image), Git auto-applies your recorded resolution. ...
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
-
Running raw git push --force rather than git push --force-with-lease on shared team feature branches when configuring rerere enabled config
git push --forceunconditionally overwrites remote commits made by teammates, whereas--force-with-leaseaborts if the remote ref was updated. - Resolving complex merge conflicts with blind checkout overwrite strategies without running unit tests when configuring rerere enabled config Unilateral conflict resolution frequently clobbers complementary logic introduced in parallel feature branches, creating regression bugs.
-
Discarding corrupted working directories prematurely instead of recovering lost state using git reflog when configuring rerere enabled config
git reflogtracks every HEAD movement, allowing instant recovery of discarded commits, botched rebases, or deleted local branches. - Disabling branch protection rules and mandatory PR approval reviews on shared release branches when configuring rerere enabled config Without branch protection, developers can bypass CI validation gates and push untested code directly to production branches.