How-to: Git clean up .orig files generated after conflict resolution

This works even if .orig has been added to .gitignore. Works for any files matching a regular expression.


After a merge conflict resolution you're often left with files ending with .orig extension. I have them added to my global .gitignore. Hence I can't easily get rid of them with regular: git clean -fd.


git clean has -e argument for a regular expression to match files. To preview what will happen:
git clean -e '!*.orig' --dry-run

To actually delete the files:
git clean -e '!*.orig' -f

It's that simple.

Dmitry Avtonomov
Software Engineer

My main research interests are data visualization and processing for mass spectrometry.