Git mergetool 生成不需要的 .orig 文件

标签 git version-control

当我使用 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 to false then this file is not preserved.
Defaults to true (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/

相关文章:

git - Linus Torvalds 说 Git "never ever"跟踪一个文件是什么意思?

xcode - 由于未跟踪的工作树文件导致 git branch checkout 出现问题

git - 在intellij中获取git diff中的所有文件

git - 如何生成每个文件类型更改的 Git 统计信息?

git - 如何恢复 git bisect

git - "checkout head"是做什么的?

git - 如何镜像Github和VS Online?

bash - 如何在不复制存储库的情况下自动从github下载文件

java - 在 Mercurial 中将稳定分支更改移回主干的正确方法

git - 显示本地(非跟踪)分支上未推送提交的数量