Hi all.  I got pretty frustrated today by some unexpected behavior of
git clean; I wonder if folks thought it was a real problem or just

One of the platforms I need to build on is Windows and we're using cmake
to generate MSVC project files.  MSVC allows you to build one of a small
number of different "types" of output, such as "Debug", "Release", etc.
Additionally, we have many different "targets" that are built: one for
each library, executable, unit test program, etc.

The way MSVC (or cmake, I'm not sure) organizes the output is that for a
source directory SRC and a target SOMELIB built for "Debug" for example,
the object files will be:


Note that here only SRC  and SRC/foo.cpp are actually part of the Git
repository; the other directories/files are not tracked.

Now, adding all the target directories ("SOMELIB.dir") to .gitignore
individually is a big pain since there are so many.  And adding "*.dir"
to .gitignore seems like it might match some stuff that we might want.

So, I added the "type" directories to .gitignore, like this:


(also, these directories are used by Mac OS Xcode so need to be ignored

This works great for "git status"; it doesn't show the "SOMELIB.dir"
directory as "untracked" because after the .gitignore stuff is through
getting rid of files that is just an empty directory.

However after some head-banging today I discovered that "git clean
-fdX" (which is what I normally use to clean out workspaces) won't
delete these files.  Apparently "git clean -X" uses a different
algorithm than "git status" for matching .gitignore contents and since
SOMELIB.dir is not ignored, "git clean" skips over it rather than
looking inside it for ignored files.

So I had this situation where I had stale object files in my workspace
and "git status" showed I had no untracked files, but "git clean -fdX"
didn't clean up the stale object files.

Does it seem incorrect to anyone else that "git clean -X" doesn't delete
all the files in your workspace that are considered ignored by "git

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to