From: "Paul Smith" <>
Sent: Friday, August 22, 2014 12:41 PM
Subject: Re: [git-users] git clean vs git status re .gitignore

On Fri, 2014-08-22 at 10:05 +0200, Magnus Therning wrote:
On Thu, Aug 21, 2014 at 10:16:08PM -0400, Paul Smith wrote:
>>> 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 status"?

Well, reading the man page for `git clean` like a lawyer (my emphasis

   -X     Remove only *files* ignored by Git. This may be useful to
          rebuild everything from scratch, but keep manually created

So, it could be argued it does what it says, it removes all *files*
ignored by git, not ignored *folders*.

Yes, but that's what the -d option is for.  You'll note that the -x
option has similar language regarding files.

I set up a small example that I hope matches your situation:

Yes, that's it.

So git doesn't want to delete the ignored *folders* Debug/ and Release/. Even
more interestingly is the behaviour when we start ignoring '*.o' too:

My take on this is that "git clean" is doing a top-down operation, and
when it comes across a file that is not in .gitignore (SOMELIB.dir) it
stops and doesn't go down any further.

For "git status" on the other hand, it DOES continue to go into
SOMELIB.dir and then due to .gitignore it ends up pruning out everything inside that directory, then it doesn't print the empty directory (since
"git status" never shows empty directories).

I would argue that raising a bug on this is called for.

OK thanks for the analysis!


There's also been a couple of recent discussions on the git list about the 'git status' listings being sometimes 'confusing', if that was part of your cross checking.

Also a while back (last year?) the gitignore processing was updated IIRC so that it stopped descending directories after negative patterns, so there may be some code conflicts about when an ignore is fully valid between the different commands.

You may also be able to repeat the issue using the new idea of "teach fast-export an --anonymize option" which could allow you to demonstrate your issue (though it may have too much anonymisation!)

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 
For more options, visit

Reply via email to