I keep running into a minor inconvenience that I would like to avoid. If I look at the set of all files I want git to ignore, I can break them into two basic groups:
-
Files that I need to keep on my file system to work on the project (IDE project metadata files, configuration files that are particular to my workstation, etc.)
-
Files that get generated that I don’t need and generally clutter up my file system when I add them to .gitignore. (compiled output, core dumps, etc.)
Ideally, I’d like git to ignore all these files so that when I’m looking at my unstaged changes I can get a clear view of the things I changed without a bunch of noise. If I add all those file to .gitignore I can get the clear picture of what I’ve changed when I do a git status. (this is the state I am in now)
However, I’d also like to be able to use git clean to blow away all the files in category 2 without removing all the files in category 1. If I only add the files in category 1, I can use git clean -x to remove all the untracked things. Unfortunately, that clutters up git status.
Alternatively, I can add all the files in category 2, but I end up having to manually remember not to add/commit my workstation-specific files. git status is pretty much continuously cluttered, but not quite as bad.
Is there a way I can get all three of these things in harmony:
- Get an clear picture of the files I care about with
git status - Remove all the files I don’t care about with
git clean - Keep all the untracked files that I don’t want to share when I run
git clean
Have a look at the fine details of the
gitignoreman page. It includes details about this case.Choose the case you desire.