# List of directories containing only ignored files

3 messages from 2011-10-06 to 2011-10-06. Participants: Marcin Wiśnicki, Andreas Ericsson.
Thread: https://gitlist.dev/t/28602

## Marcin Wiśnicki, 2011-10-06 13:56

Subject: List of directories containing only ignored files
Message-ID: <CAC9GOO__nN9W1vvoMxq2LKnn=YoFPjTE6jKPbQ2h7im3JtujQA@mail.gmail.com>
URL: https://gitlist.dev/e/CAC9GOO__nN9W1vvoMxq2LKnn%3DYoFPjTE6jKPbQ2h7im3JtujQA%40mail.gmail.com

```
What's the easiest way to find all directories that contain only
ignored files but are not ignored themselves.

For example, given following .gitignore:

  obj/

and following files:

  /project1/foo.c
  /project1/obj/foo.o
  /project2/obj/bar.o

Where /project2 contains leftovers from different branch that are not
cleared on switch because they are ignored.

I would like to see:

  /project2


Alternatively: how to remove such leftovers when switching branches ?

```

## Andreas Ericsson, 2011-10-06 14:03

Subject: Re: List of directories containing only ignored files
Message-ID: <4E8DB548.5030108@op5.se>
URL: https://gitlist.dev/e/4E8DB548.5030108%40op5.se
In-Reply-To: <CAC9GOO__nN9W1vvoMxq2LKnn=YoFPjTE6jKPbQ2h7im3JtujQA@mail.gmail.com>

```
On 10/06/2011 03:56 PM, Marcin Wiśnicki wrote:
>
> Alternatively: how to remove such leftovers when switching branches ?

git clean -X -f

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

```

## Marcin Wiśnicki, 2011-10-06 14:32

Subject: Re: List of directories containing only ignored files
Message-ID: <CAC9GOO_edkZxU=eO93fuCiV0vFaQjcnj7u8FUPYs-1hXrQX48A@mail.gmail.com>
URL: https://gitlist.dev/e/CAC9GOO_edkZxU%3DeO93fuCiV0vFaQjcnj7u8FUPYs-1hXrQX48A%40mail.gmail.com
In-Reply-To: <4E8DB548.5030108@op5.se>

```
2011/10/6 Andreas Ericsson <ae@op5.se>:
> On 10/06/2011 03:56 PM, Marcin Wiśnicki wrote:
>>
>> Alternatively: how to remove such leftovers when switching branches ?
>
> git clean -X -f
>

That also would delete /project1/obj/foo.o which is not what I wanted.

Anyway I think I have found the answer:

 git ls-files -o --directory --exclude-standard

```
