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?
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.
git config --global mergetool.keepBackup false
, Solved for P4Merge on Mavericks 10.9.2. Thanks :) β
Interlocutor .gitignore
for opendiff generated files in here. may be useful for someone ;) β
Alliteration keepBackup = false
under [mergetool]
, not under [mergetool "BeyondCompare4"]
or whatever visual merge tool you have configured. β
Loria find . -name \*.orig
to find these files and find . -name \*.orig -delete
to delete them β
Wear 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. β
Sadducee rm ./**/*.orig
is a shorter alternative to the find command. β
Nunes 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 ;) β
Photochemistry .
. Wouldn't be too good to do rm /**/*.orig
. β
Nunes 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)
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 β
Glenn git config --global mergetool.keepBackup false
have to be set? β
Glenn The option to save the .orig file can be disabled by configuring KDiff3
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.
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" "
}
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
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.
Or just add
*.orig
to your global gitignore
git config --global mergetool.keepBackup false
This should work for Beyond Compare (as mergetool) too
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
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.
© 2022 - 2024 β McMap. All rights reserved.