Nâng CaoGit iconGit

`git rerere` là gì? Khi nào nó cứu bạn khỏi resolve cùng conflict nhiều lần?

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:

bash
git config --global rerere.enabled true

Khi 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:

bash
git rerere diff    # xem resolutions đã ghi nhớ
git rerere forget  # xóa 1 resolution nếu sai

Lư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.

Xem toàn bộ Git cùng filter theo level & chủ đề con.

Mở danh sách Git