I had to resolve merge conflicts for a few commits today after rebasing my current work. Each time I resolved the merge a pre-merge version of the file was left (with the .orig file type) and by the second merge I was over having to remove that file manually afterwards.
I wasn’t entirely sure why the files are left as I do have mergetool.keepBackup configured to false and while doing some research I found kghastie’s solution on StackOverflow. I adapted that to the PowerShell function below.
I’ve set this up in my PowerShell user profile so now all I need to do is run git-rm-orig and I get prompted to delete any .orig files in the repo. Thanks kghastie for the solution!