Keeping Your Git Repo Clean of .orig Files!
One good habit that team can do when building their project in a Git repository, is merging and rebasing as often as possible.
A good reason for this is that you’ll have much easier and manageable conflicts. Another reason is simplicity, in my experience the problems that people encounter with Git are often a result of their own choice towards complexity, i.e. complex branching hierarchies.
Keep things simple!
But I digress, the topic of this post is how to clean up .orig files that may occur and build-up in your project’s repository.
git cleanOne command that you’ll find quite useful is
git clean, it removes untracked files from the working tree of your project. Most often you’ll use it like so:git clean -fdThe reason for this is that
git cleanwon’t even run unless you give it the-fargument and-dwill also remove directories that not under version control.Another useful argument is
-nwhich will do a dry-run and show you what would be removed:git clean -ndConfigure your mergetool
You can also configure you mergetool to not preserve the .orig files, however not all Git mergetool’s support this feature and still preserve the .orig files even with this configuration:
git config --global mergetool.keepBackup falseJust ignore them!
Add this to your project’s .gitignore file:
*.origThis is the most simplest of all solutions and ultimately probably the best, if this what you choose to do the
git cleanwill still be able to clean them but you will have to invoke it with the-xargument:git clean -fdx
If you’re already ignoring a lot of files or have files ignored that you need for your Development environment e.g. tags, logs, or config files then you just need to stipulate the path you want cleaned so they aren’t removed:
git clean -fdx app