Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git mergetool generates unwanted .orig files

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 not create that extra file?

like image 327
Akeem Avatar asked Aug 09 '09 16:08

Akeem


People also ask

What are .orig files?

An ORIG file is a file that may have been created by various programs. It stores a backup copy of a file, which has been renamed with the . orig extension so that the user knows it is the original. ORIG files are most often created manually by a user rather than by a program.

What is Mergetool in git?

DESCRIPTION. Use git mergetool to run one of several merge utilities to resolve merge conflicts. It is typically run after git merge. If one or more <file> parameters are given, the merge tool program will be run to resolve differences on each file (skipping those without conflicts).

What do I do after git Mergetool?

It's generally best to take that message and add any extra information rather than write your own from scratch. Developers who use git will automatically recognize git's merge commits but may not recognize your custom merge messages immediately.

How do I use Mergetool meld in git?

git mergetool allows you to use a GUI merge program (i.e. Meld) to resolve the merge conflicts that have occurred during a merge. Like difftool you can set the GUI program on the command line using -t <tool> / --tool=<tool> but, as before, it makes more sense to configure it in your . gitconfig file.


1 Answers

A possible solution from git config:

git config --global mergetool.keepBackup false 

After performing a merge, the original file with conflict markers can be saved as a file with a .orig extension.
If this variable is set to false then this file is not preserved.
Defaults to true (i.e. keep the backup files).

The alternative being not adding or ignoring those files, as suggested in this gitguru article,

git mergetool saves the merge-conflict version of the file with a “.orig” suffix.
Make sure to delete it before adding and committing the merge or add *.orig to your .gitignore.

Berik suggests in the comments to use:

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

Charles Bailey advises in his answer to be aware of internal diff tool settings which could also generate those backup files, no matter what git settings are.

  • kdiff3 has its own settings (see "Directory merge" in its manual).
  • other tools like WinMerge can have their own backup file extension (WinMerge: .bak, as mentioned in its manual).

So you need to reset those settings as well.

like image 50
VonC Avatar answered Sep 19 '22 18:09

VonC