How to fix Recorded preimage for 'file.txt' but resolution failed in Git
Git rerere (reuse recorded resolution) failed to automatically apply a previously recorded conflict resolution. This happens when the cached resolution no longer matches the current conflict context.
Quick fix
Fixes Recorded preimage for 'file.txt' but resolution failed
git rerere status- Check which files have failed rerere resolution
- Manually resolve the conflict
- Forget the bad cached resolution
- Continue the merge or rebase operation
git rerere statusRecorded preimage for 'file.txt' but resolution failed
What this error means
Git rerere is a feature that records how you resolve merge conflicts and automatically reuses those resolutions when the same conflict appears again. The 'resolution failed' error occurs when rerere finds a matching conflict fingerprint in its cache (.git/rr-cache), but the three-way merge between the earlier conflict, the recorded resolution, and the current conflict cannot be applied cleanly. This typically happens because the code context has changed significantly since the original resolution was recorded, or the conflict structure has evolved in ways that make the cached resolution incompatible. Git tries to help by replaying your previous fix, but when the replay fails, it falls back to showing you the original conflict markers. Unlike a simple merge conflict, this error indicates that Git attempted to help using rerere but encountered an inconsistency between what was recorded and what currently exists in your working tree.
Typical symptoms
- Message: 'Recorded preimage for FILE but resolution failed'
- Message: 'Resolved FILE using previous resolution'
- Merge conflict markers still appear in files after rerere attempts resolution
- git rerere status shows files that could not be auto-resolved
- git rerere remaining lists paths with unresolved conflicts
- Rebase or merge operations pause with conflicts despite rerere being enabled
Common causes
- Code context around the conflict has changed significantly since the original resolution
- Conflict markers in the file that look like actual code confuse rerere fingerprinting
- Unmatched or improperly nested conflict markers prevent rerere from tracking the conflict
- Conflicting submodules, which rerere cannot track or resolve automatically
- Corrupt or incomplete entries in the .git/rr-cache directory
- Different conflict structure between original and current merge (e.g., different number of conflict hunks)
- Modified files during a rebase sequence that change the conflict context
How to fix "Recorded preimage for 'file.txt' but resolution failed"
Use git rerere to see the status of recorded resolutions:
git rerere statusTo see which conflicts still need manual resolution:
git rerere remainingThis shows files that rerere couldn't resolve, including submodules and files with tracking issues.
Open the conflicted file and resolve it manually as you would any merge conflict:
1. Look for conflict markers: <<<<<<<, =======, >>>>>>>
2. Edit the file to resolve the conflict
3. Remove all conflict markers
4. Save the file
After resolving, stage the file:
git add <file>Git will record this new resolution for future use.
If rerere keeps applying an incorrect resolution, remove it from the cache:
git rerere forget <file>Note: You must apply the bad resolution first (by doing the merge), THEN forget it, THEN reset and redo the merge:
# After merge applies bad resolution
git rerere forget <file>
git reset --hard origin/<branch>
# Now redo the merge and resolve correctlyTo clear all rerere cache completely:
rm -rf .git/rr-cacheAfter resolving conflicts and staging files, continue your operation:
For rebase:
git rebase --continueFor merge:
git commitFor cherry-pick:
git cherry-pick --continueGit will now record the new resolution in rerere cache for future conflicts.
Always verify that rerere-assisted resolutions are correct:
# Review the changes
git diff
# Run your tests
npm test # or your test commandNote: git rerere leaves the index file alone and doesn't automatically stage files. You must always inspect results and run tests before committing.
Advanced notes
Git rerere works by taking a fingerprint of conflicts and pairing them with fix fingerprints. The cache is stored in .git/rr-cache/, where each conflict gets a directory with 'preimage' (conflict state), 'postimage' (resolved state), and 'thisimage' files.
Conflict Marker Issues: If your code contains lines that look like conflict markers (e.g., documentation examples showing <<<<<<< or =======), rerere may fail. Use the conflict-marker-size setting in .gitattributes to work around this: 'file.txt conflict-marker-size=32'.
Garbage Collection: By default, unresolved conflicts older than 15 days and resolved conflicts older than 60 days are pruned via 'gc.rerereUnresolved' and 'gc.rerereResolved' config variables.
Sharing Rerere Cache: Teams can share rerere resolutions via a dedicated branch in the repository, or use 'rerere-train.sh' to learn resolutions from existing Git history. This helps team members automatically benefit from conflict resolutions made by others.
Long-lived Feature Branches: A key use case for rerere is maintaining long-lived topic branches. You can periodically attempt merges with the main branch, resolve conflicts, then back out (git reset --hard). When the final merge happens, rerere will apply all previously recorded resolutions automatically.
Frequently asked questions
- What does "Recorded preimage for 'file.txt' but resolution failed" mean?
- Git rerere is a feature that records how you resolve merge conflicts and automatically reuses those resolutions when the same conflict appears again. git/rr-cache), but the three-way merge between the earlier conflict, the recorded resolution, and the current conflict cannot be applied cleanly. This typically happens because the code context has changed significantly since the original resolution was recorded, or the conflict structure has evolved in ways that make the cached resolution incompatible.
- How do I fix "Recorded preimage for 'file.txt' but resolution failed"?
- Git rerere (reuse recorded resolution) failed to automatically apply a previously recorded conflict resolution. This happens when the cached resolution no longer matches the current conflict context.
- What causes "Recorded preimage for 'file.txt' but resolution failed"?
- Code context around the conflict has changed significantly since the original resolution Conflict markers in the file that look like actual code confuse rerere fingerprinting Unmatched or improperly nested conflict markers prevent rerere from tracking the conflict
- Is the "Recorded preimage for 'file.txt' but resolution failed" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Git Official Documentation
- ๐Docs: Git Rerere(Official Docs)
- ๐Docs: git-rerere(Official Docs)
- ๐