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?
This question is related to
git
version-control
Windows:
Win/Users/HOME/.gitconfig
set mergetool.keepTemporaries=false
git/libexec/git-core/git-mergetool
, in the function cleanup_temp_files()
add rm -rf -- "$MERGED.orig"
within the else block.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
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.
git config --global mergetool.keepBackup false
This should work for Beyond Compare (as mergetool) too
Or just add
*.orig
to your global gitignore
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.
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)
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" "
}
The option to save the .orig file can be disabled by configuring KDiff3
Source: Stackoverflow.com