Question

In a project I am working on I am using git and eclipse, eclipse creates a .project file in the project root. When I do a git clean I do not want to remove this file as I have to create this again.

I do want git clean to remove excluded files and directories (since compiled files are excluded).

Normally I do git clean -xdf which suits my needs, however I have to exclude the .project file each time (git clean -xdf -e .project).

Simply putting the .project in a (global) gitignore file doesn't do the trick, prefixing it with a ! also doesn't quite fix this as it then shows up in git status.

So I'm looking to exclude instead of ignore, but I cannot find a git-clean-exclude setting. Did anyone ran into this, and if so how did they solve it?

Was it helpful?

Solution

I'm not aware of any built-in way to achieve that. However, you could easily create an alias for this, to make it less of a hassle:

$ git config alias.xclean "clean -xdf -e .project"

Then you can just run git xclean and it will do what you want.

This example configures the alias only for the local working tree. To have it for all git repos on your machine, add the --global flag to git config.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top