Git mergetool generates unwanted .orig files

前端 未结 10 1953
予麋鹿
予麋鹿 2020-11-30 16:16

When I do a merge conflict resolution with Kdiff3 (and other merge tool I tried) I noticed that on resolution a *.orig file is created. Is there a way for it to

相关标签:
10条回答
  • 2020-11-30 16:25
    git config --global mergetool.keepBackup false
    

    This should work for Beyond Compare (as mergetool) too

    0 讨论(0)
  • 2020-11-30 16:27

    Besides the correct answers offered as long term solutions, you can use git to remove all unnecessary files once for you with the git clean -f command but use git clean --dry-run first to ensure nothing unintended would happen.

    This has the benefit of using tested built in functionality of Git over scripts specific to your OS/shell to remove the files.

    0 讨论(0)
  • I use this to clean up all files ending in ".orig":

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

    If you are a scaredy-cat :) you could leave the last part off just to list them (or leave off the -r if you want to approve each delete):

    function git-show-orig {
        git status -su | grep -e"\.orig$" | cut -f2 -d" "
    }
    
    0 讨论(0)
  • 2020-11-30 16:38

    Or just add

    *.orig

    to your global gitignore

    0 讨论(0)
  • 2020-11-30 16:39

    Windows:

    1. in File Win/Users/HOME/.gitconfig set mergetool.keepTemporaries=false
    2. in File git/libexec/git-core/git-mergetool, in the function cleanup_temp_files() add rm -rf -- "$MERGED.orig" within the else block.
    0 讨论(0)
  • 2020-11-30 16:41

    The option to save the .orig file can be disabled by configuring KDiff3

    KDiff3 Backup file .orig option

    0 讨论(0)
提交回复
热议问题