rerere = Reuse Recorded Resolution: git ghi nhớ cách bạn resolve conflict, và tự động replay resolution đó khi gặp cùng conflict.
Enable:
git config --global rerere.enabled trueKhi nào cứu bạn:
Scenario 1 - Long rebase: feature branch 20 commits, rebase lên main, commit thứ 3 có conflict X. Bạn resolve. Commit thứ 15 có cùng conflict X → rerere tự resolve.
Scenario 2 - Release branch: merge release branch vào main mỗi tháng, cùng một config conflict xuất hiện mỗi lần → rerere nhớ, không cần resolve lại.
Scenario 3 - Topic branches: nhiều feature branches merge vào integration branch để test, cùng conflict xuất hiện nhiều lần qua ngày → rerere tái dùng resolution.
Cách hoạt động:
git rerere diff # xem resolutions đã ghi nhớ
git rerere forget # xóa 1 resolution nếu saiLưu ý: rerere chỉ hoạt động nếu conflict markers giống hệt nhau (same file, same context lines).
Nếu code xung quanh thay đổi, rerere không match được.
rerere = Reuse Recorded Resolution: git memorizes how you resolved a conflict and automatically replays that resolution when it encounters the same conflict again.
Enable:
git config --global rerere.enabled trueWhen it saves you:
Scenario 1 - Long rebase: feature branch with 20 commits rebasing onto main, commit 3 has conflict X. You resolve it. Commit 15 has the same conflict X → rerere auto-resolves.
Scenario 2 - Release branch: merging a release branch into main every month, the same config conflict appears each time → rerere remembers, no manual resolution needed.
Scenario 3 - Topic branches: multiple feature branches merging into an integration branch for testing, same conflict appears many times through the day → rerere reuses the resolution.
How to inspect:
git rerere diff # view memorized resolutions
git rerere forget # delete a resolution if it was wrongNote: rerere only works when conflict markers are identical (same file, same context lines).
If surrounding code changed, rerere cannot match the conflict.