多人分支反复 rebase 或合并时,同一段冲突可能出现好几次。Git 的 rerere 可以记住你解决过的冲突,下次先把结果套上:
git config --global rerere.enabled true
git config --global rerere.autoupdate true
第一次仍需手动改完并 git add,之后遇到相同冲突 Git 会尝试复用;git rerere status 看当前记录,git rerere diff 看它准备应用的差异。开了 rerere.autoupdate 也建议在提交前检查 diff 并跑测试,冲突上下文变了时不要盲信。想清掉某次错误记录,可以在解决冲突后执行 git rerere forget path/to/file。
Git 2.x、任意 Git 仓库都能试,不会改项目文件之外的配置;命令里的 --global 会写入当前用户配置,不想影响其他仓库的话可以去掉。