For teams building projects with Git, a good habit is to rebase and merge often so conflicts are less frequent and easier to resolve. Also, this helps keeps your branch graph simple. When people have to make complicated merges, it’s often because their branch graph is complex.
Keep things simple!
This post’s topic: How to clean up .orig files that have built up in your project’s repository from merges.
git cleanremoves untracked files from the working tree of your project. You’ll usually run it like so:
git clean -fd
git cleanwon’t even remove any files unless you give it the
-dtells Git to remove the directories that aren’t under version control — along with the files.
git cleanwill do a dry-run and show you what it will remove:
git clean -nd
Configure your mergetool
You can configure you mergetool to not preserve the .orig files, however not all Git mergetool’s support this feature and some still preserve the .orig files even with this configuration:
git config --global mergetool.keepBackup false
Just ignore them!
Add this to your project’s .gitignore file:
With this setup, you don’t have to worry about checking these files into your repo. The files will still be on your disk though, and when you want to clean them you’ll need to pass the
git clean -fdx
If you have files ignored that you need for your Development environment e.g. tags, logs, or config files then make sure you stipulate the path you want cleaned so the files you need aren’t removed:
git clean -fdx app