当我使用 Kdiff3(以及我尝试过的其他 merge 工具)执行 merge 冲突解决时,我注意到在解决时创建了一个 *.orig
文件。有没有办法让它不创建那个额外的文件?
最佳答案
来自 git config
的可能解决方案:
git config --global mergetool.keepBackup false
After performing a merge, the original file with conflict markers can be saved as a file with a
.orig
extension.
If this variable is set tofalse
then this file is not preserved.
Defaults totrue
(i.e. keep the backup files).
替代方法是不添加或忽略这些文件,如本 gitguru article 中所建议的那样,
git mergetool
saves the merge-conflict version of the file with a “.orig
” suffix.
Make sure to delete it before adding and committing the merge or add*.orig
to your.gitignore
.
Berik建议 in the comments使用:
find . -name \*.orig
find . -name \*.orig -delete
Charles Bailey建议 his answer了解内部差异工具设置,无论 git 设置是什么,它也可以生成这些备份文件。
- kdiff3 有自己的设置(参见其手册中的“Directory merge”)。
- WinMerge 等其他工具可以有自己的备份文件扩展名(WinMerge:
.bak
,如 its manual 中所述)。
因此您还需要重置这些设置。
关于Git mergetool 生成不需要的 .orig 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1251681/