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?
-
Finally I googled this damn thing. Thank you for asking this question – unkulunkulu May 02 '23 at 16:00
11 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 tofalse
then this file is not preserved.
Defaults totrue
(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.

- 1,262,500
- 529
- 4,410
- 5,250
-
18Editing the settings in kdiff itself worked for me: Settings > Configure Kdiff3 > Directory. Uncheck the box labeled "Backup files (.orig)" – kmgdev Sep 05 '13 at 18:46
-
2`git config --global mergetool.keepBackup false`, Solved for P4Merge on Mavericks 10.9.2. Thanks :) – kpsfoo Apr 08 '14 at 23:57
-
found a set of `.gitignore` for opendiff generated files [in here](https://github.com/sebreh/SBRXCallbackURLKit/blob/master/.gitignore). may be useful for someone ;) – Hlung May 22 '14 at 09:05
-
@Hlung Interesting. That should be added or referenced in https://github.com/github/gitignore or http://www.gitignore.io/ – VonC May 22 '14 at 09:09
-
-
6Note that if you're manually editing your .gitconfig, you want the `keepBackup = false` under `[mergetool]`, not under `[mergetool "BeyondCompare4"]` or whatever visual merge tool you have configured. – TrueWill Sep 19 '16 at 19:19
-
git config --global mergetool.keepBackup false, solved for DiffMerge the problem too! Many thanks! It was so useful – harryssuperman Jan 13 '17 at 09:46
-
You may want to use `find . -name \*.orig` to find these files and `find . -name \*.orig -delete` to delete them – Berik Oct 12 '17 at 15:36
-
I have been using `git clean -f` to remove unwanted `.orig` files. This may be a simpler move, but is probably an indicator of how little I know about git. – Tim Randall Sep 20 '18 at 13:11
-
`rm ./**/*.orig` is a shorter alternative to the find command. – Benjamin Hammer Nørgaard Sep 26 '19 at 09:02
-
@BenjaminHammerNørgaard True. But I always prefer to `find` (list files) first, check that what I am about to delete is indeed what I want, *then* delete it. Using `rm` with wildcards (`*` or `**`) is anxiety-inducing for me ;) – VonC Sep 26 '19 at 09:06
-
@VonC but if you are in a git repo it's not that hard to undo a mistake. Just don't forget the `.`. Wouldn't be too good to do `rm /**/*.orig`. – Benjamin Hammer Nørgaard Sep 27 '19 at 10:03
You have to be a little careful with using kdiff3
as while git mergetool
can be configured to save a .orig
file during merging, the default behaviour for kdiff3
is to also save a .orig
backup file independently of git mergetool
.
You have to make sure that mergetool
backup is off:
git config --global mergetool.keepBackup false
and also that kdiff3's settings are set to not create a backup:
Configure/Options => Directory Merge => Backup Files (*.orig)

- 755,051
- 104
- 632
- 656
-
4`Configure/Options => Directory Merge => Backup Files (*.orig)` really helped get rid of all the strange io-slave, klauncher «» unknown protocol, and couldn't create .orig errors. thank you – Geremia Jun 22 '16 at 20:10
-
2Why does `git config --global mergetool.keepBackup false` have to be set? – Geremia Jun 22 '16 at 20:12
-
1let me fix your first line "You have to be a little crazy to use kdiff3" - there :-) – Tim Jarvis Jan 25 '19 at 03:15
-
1@TimJarvis I use kdiff3 all the time and I like it. I wonder if there is a reason for calling it "a little crazy to use kdiff3" or if that is just joking (I see the smiley face, I won't be offended either way, I'm earnestly asking) – Quinn Wilson Mar 05 '20 at 14:32
-
@QuinnWilson It was mostly just a joke - there are many better tools than kdiff3 though, if you like it you will probably absolutely love tools like p4Merge etc. – Tim Jarvis Jun 17 '20 at 03:57
To be clear, the correct git command is:
git config --global mergetool.keepBackup false
Both of the other answers have typos in the command line that will cause it to fail or not work correctly.

- 29,546
- 11
- 78
- 79
The option to save the .orig file can be disabled by configuring KDiff3

- 1,834
- 17
- 16
-
5
-
-
1I already had the global git config set properly but still had those .orig files on rebase/merge etc. The Kdiff3 settings finally did the trick. – Cécile Fecherolle Mar 21 '18 at 08:29
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" "
}

- 739
- 1
- 7
- 14
-
1Totally useful if you still want the backups until you get ready to commit. – Kelly Dec 05 '12 at 16:25
-
5You could also add *.orig in .gitignore on the top level if you keep merge backups around. – Ville Nov 05 '13 at 23:55
I simply use the command
git clean -n *.orig
check to make sure only file I want remove are listed then
git clean -f *.orig

- 211
- 2
- 2
-
2A good tip! It would be good if you also added the other answers regarding gitconfig settings (from other answers). – AzP Feb 11 '19 at 15:21
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.

- 1,438
- 3
- 16
- 30
-
6Yes, but be very careful as this command does a lot more than remove the .orig files. – kghastie Nov 06 '13 at 17:14
Or just add
*.orig
to your global gitignore

- 823
- 2
- 14
- 33
-
3Not a huge fan because it still leaves garbage in your local repository. – Kellen Stuart Mar 12 '21 at 23:17
git config --global mergetool.keepBackup false
This should work for Beyond Compare (as mergetool) too

- 81
- 7
If you're working on a Windows machine - you can turn off backups with this command
git config --global mergetool.keepBackup false
If you don't want to do that, you can easily delete all the .orig
files using this powershell command
ls -Recurse C:\path\to\repository\*.orig | rm

- 7,775
- 7
- 59
- 82
Windows:
- in File
Win/Users/HOME/.gitconfig
setmergetool.keepTemporaries=false
- in File
git/libexec/git-core/git-mergetool
, in the functioncleanup_temp_files()
addrm -rf -- "$MERGED.orig"
within the else block.
-
1See the accepted answer. This modifies core tools and is not scalable. – oligofren Dec 06 '16 at 11:44