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?
-
1possible duplicate of [Diff tool generates unwanted .orig files](http://stackoverflow.com/questions/1251681/diff-tool-generates-unwanted-orig-files) – Shoe Jan 21 '13 at 14:42
-
Possible duplicate of [Git mergetool generates unwanted .orig files](https://stackoverflow.com/questions/1251681/git-mergetool-generates-unwanted-orig-files) – ruffin May 27 '17 at 11:37
5 Answers
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:

- 74,247
- 24
- 188
- 156

- 3,413
- 20
- 23
-
I've got response: $ git config global mergetool.keepBackup false error: key does not contain a section: global – Eugene Oct 10 '11 at 13:02
-
Sorry for the late response but i'm putting it here for any future visitors. You forgot to add - infront of global when you called git config. -global is a flag that tells git to operate on the global (per machine) configuration instead of the local per repository one. – Simon Stender Boisen Nov 29 '11 at 15:40
-
3Watch out for the dash infront of -global -- because of the formatting that dash is not compatible with the command line. Use this `git config --global mergetool.keepBackup false` – Alex Le Dec 06 '11 at 05:09
-
1The orig files may also be created by the external merge tool (kdiff3). See this Q/A: http://stackoverflow.com/questions/1251681/diff-tool-generates-unwanted-orig-files – kevinarpe Feb 15 '13 at 10:06
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:
- open KDiff3,
- go to Settings / Configure KDiff3 / Directory,
- un-tick checkbox "Backup files (.orig)"

- 5,584
- 2
- 26
- 26
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
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.

- 4,488
- 1
- 21
- 22
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.