Best solution in this case is to keep it simple and get rid of those files independently of git:
cd /your/repo/directory
find . -name '*.orig' -delete
Alternatively, in Windows/PowerShell, you can run the following command
cd \your\repo\directory
Get-ChildItem -Recurse -Filter '*.orig' | Remove-Item
Try git clean
more info you can find here or here
you can do:
git config --global mergetool.keepBackup false
For more info, refer to to Git mergetool generates unwanted .orig files
Unfortunately git clean
doesn't work for me because I have *.orig
added to my global gitignore file, so they're ignored from clean as well. Even running git clean -x
is no good because I don't want all of my ignored files getting deleted. git clean -i
is helpful, but really I don't want to have to review each and every file.
However, we can use an exclude pattern and negate the match. Preview with this command:
git clean -e '!*.orig' --dry-run
Then when you're confident, pass the force
flag to really delete them:
git clean -e '!*.orig' -f
Based on leorleor's comment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With