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*.

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

% tree
└── SRC
    ├── foo.cxx
    └── SOMELIB.dir
        ├── Debug
        │   └── foo.cxx.o
        └── Release
            └── foo.cxx.o

4 directories, 3 files

% cat .gitignore 

% git status 
On branch master
nothing to commit, working directory clean

% git clean -ndX

% git clean -ndx
Would remove SRC/SOMELIB.dir/

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:

% print '*.o' >> .gitignore 

% git clean -ndX           

% git clean -ndx
Would remove SRC/SOMELIB.dir/

That is, `git clean -ndX` won't remove ignored files located in ignored folders!

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


Magnus Therning                      OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe               http://therning.org/magnus

Goto labels should be left-aligned in all caps and should include the
programmer's name, home phone number, and credit card number.
     -- Abdul Nizar

Attachment: pgpUKJ7A8G8pQ.pgp
Description: PGP signature

Reply via email to