How to delete .orig files after merge from git repository?
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
You can ignore files using .gitignore
Just put *.orig in the list like shown here
https://help.github.com/articles/ignoring-files
for deleting current files you can create shell script and run from project folder like below
for file in `find *.orig -type f -print`
do
echo "Deleting file $file"
git rm $file -f
done