Avoid orphaned .orig files after resolving conflicts from a Git merge

After I perform a Git merge and resolve the conflicts, there are leftover .orig versions of the conflicting files. How can I automatically delete those after the conflict is successfully resolved?

  • Git won't let me merge
  • Composer & composer.lock in GIT and merge conflicts
  • Merge two git repos into one without renaming files
  • git :: merge files from different folders in local and remote branch
  • Is it OK to merge another branch into mine and then merge both into master
  • What are the conceptual differences between Merging, Stashing and Rebasing in Git?
  • Is creating git diff patches then manually editing the before applying a valid workflow?
  • How to resolve conflict with remote git repo?
  • 5 Solutions collect form web for “Avoid orphaned .orig files after resolving conflicts from a Git merge”

    It’s the git mergetool that produces these files, you can disable them with this command:

    git config --global mergetool.keepBackup false
    

    See the git-config manpage:

    http://man.he.net/man1/git-config

    I think this should work:

    git status -su | grep -e"\.orig$" | cut -f2 -d" " | xargs rm
    

    See https://stackoverflow.com/a/10744524/670915 for details

    Quite likely those files are created by KDiff3 tool you probably using for merging files. The easiest way to solve the problem is where it was originated:

    1. open KDiff3,
    2. go to Settings / Configure KDiff3 / Directory,
    3. un-tick checkbox “Backup files (.orig)

    Git doesn’t create *.orig files. It only marks the sections in the conflicting file with <<<< ... ==== ... >>>>.

    Which tool are you using? You’ll have to disable it there.

    But tools like WinMerge indeed create these files, but they automatically process and remove them when you mark the file as resolved within the editor.

    Even I was geting the same error, when I copy + paste the command from a word document. But I tried removing the -- before the switch global and re-type it manually on the command prompt. It WORKED!

    May be it was due to some mis-interpretation of the Charectes in the MS_Wrod and the Command Prompt.

    Git Baby is a git and github fan, let's start git clone.