Eugene
Eugene

Reputation: 60184

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?

Upvotes: 41

Views: 6768

Answers (5)

VeganHunter
VeganHunter

Reputation: 5984

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)"

Upvotes: 5

adubr
adubr

Reputation: 777

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

Upvotes: 1

SVS
SVS

Reputation: 9

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.

Upvotes: -1

Simon Stender Boisen
Simon Stender Boisen

Reputation: 3431

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

Upvotes: 54

Grad van Horck
Grad van Horck

Reputation: 4506

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.

Upvotes: 0

Related Questions