代码之家  ›  专栏  ›  技术社区  ›  Akeem

Git合并工具生成不需要的.orig文件

  •  571
  • Akeem  · 技术社区  · 17 年前

    *.orig

    11 回复  |  直到 11 年前
        1
  •  836
  •   VonC    8 年前

    一个可能的解决方案 git config

    git config --global mergetool.keepBackup false
    

    .orig
    如果此变量设置为 false 则不保留此文件。
    默认为 true

    另一种选择是不添加或忽略这些文件,如本文所述 gitguru article

    git mergetool .orig 后缀。
    *.orig 给你的 .gitignore .

    Berik 建议 in the comments

    find . -name \*.orig 
    find . -name \*.orig -delete
    

    Charles Bailey his answer 无论git设置如何,它也可以生成这些备份文件。

        2
  •  89
  •   CB Bailey    16 年前

    使用时必须小心一点 kdiff3 git mergetool .orig .orig git合并工具 .

    mergetool

    git config --global mergetool.keepBackup false
    

    Configure/Options => Directory Merge => Backup Files (*.orig)
    
        3
  •  36
  •   xx1xx    11 年前

    git config --global mergetool.keepBackup false
    

    其他两个答案在命令行中都有拼写错误,这将导致它失败或无法正常工作。

        4
  •  35
  •   John    16 年前

    KDiff3 Backup file .orig option

        5
  •  25
  •   kghastie    12 年前

    我用它来清理所有以“.orig”结尾的文件:

    function git-clean-orig {
        git status -su | grep -e"\.orig$" | cut -f2 -d" " | xargs rm -r
    }
    

    如果你是一只胆小的猫:)你可以省略最后一部分,只是为了列出它们(或者省略 -r 如果要批准每次删除):

    function git-show-orig {
        git status -su | grep -e"\.orig$" | cut -f2 -d" "
    }
    
        6
  •  14
  •   Rodneyk    9 年前

    我只是使用命令

    git clean -n *.orig
    

    然后

    git clean -f *.orig
    
        7
  •  10
  •   haleonj    12 年前

    git clean -f git clean --dry-run 首先要确保不会发生意外。

    这有利于使用Git经过测试的内置功能,而不是特定于OS/shell的脚本来删除文件。

        8
  •  5
  •   cd491415    8 年前

    向您的全球gitignore致敬

        9
  •  3
  •   Atul    11 年前
    git config --global mergetool.keepBackup false
    

    这也适用于Beyond Compare(作为合并工具)

        10
  •  0
  •   pagid    11 年前

    如果您在Windows计算机上工作,则可以使用此命令关闭备份

    git config --global mergetool.keepBackup false
    

    .orig

    ls -Recurse C:\path\to\repository\*.orig | rm
    
        11
  •  0
  •   Kellen Stuart Alan    5 年前

    窗户:

    1. 在文件中 Win/Users/HOME/.gitconfig mergetool.keepTemporaries=false
    2. 在文件中 git/libexec/git-core/git-mergetool cleanup_temp_files() rm -rf -- "$MERGED.orig"