# git clean -Xdf doesn't clean ignored files in subfolders

4 messages from 2020-11-02 to 2020-11-03. Participants: David Besen, Elijah Newren.
Thread: https://gitlist.dev/t/54558

## David Besen, 2020-11-02 22:44

Subject: git clean -Xdf doesn't clean ignored files in subfolders
Message-ID: <CAHqVHwt1QJjXCAbDD5ViZ1E_rD8u+H_XeJ=FOv4VFPTS8y3xjg@mail.gmail.com>
URL: https://gitlist.dev/e/CAHqVHwt1QJjXCAbDD5ViZ1E_rD8u%2BH_XeJ%3DFOv4VFPTS8y3xjg%40mail.gmail.com

```
Hi!

I'm seeing some unexpected behavior with git clean:

git init test
cd test
echo "ignored.txt" > .gitignore
mkdir folder
touch folder/ignored.txt
git clean -Xdf

I'd expect this to delete folder/ignored.txt, and instead it doesn't.
I'm in git 2.29.2 on osx.

I saw that git clean -xdn does delete the file, so if this is a bug
it's limited to -X.

Thanks!
Dave

```

## Elijah Newren, 2020-11-03 17:11

Subject: Re: git clean -Xdf doesn't clean ignored files in subfolders
Message-ID: <CABPp-BEF2wqP+Cx5-6yq6cfQ1Pa+8iOXWR11DNBH02yh-D8oFg@mail.gmail.com>
URL: https://gitlist.dev/e/CABPp-BEF2wqP%2BCx5-6yq6cfQ1Pa%2B8iOXWR11DNBH02yh-D8oFg%40mail.gmail.com
In-Reply-To: <CAHqVHwt1QJjXCAbDD5ViZ1E_rD8u+H_XeJ=FOv4VFPTS8y3xjg@mail.gmail.com>

```
On Mon, Nov 2, 2020 at 2:46 PM David Besen <dbesen@gmail.com> wrote:
>
> Hi!
>
> I'm seeing some unexpected behavior with git clean:
>
> git init test
> cd test
> echo "ignored.txt" > .gitignore
> mkdir folder
> touch folder/ignored.txt
> git clean -Xdf
>
> I'd expect this to delete folder/ignored.txt, and instead it doesn't.
> I'm in git 2.29.2 on osx.
>
> I saw that git clean -xdn does delete the file, so if this is a bug
> it's limited to -X.

Is this the same issue as reported at
https://lore.kernel.org/git/4F1384AE.1050209@pcharlan.com/?

```

## David Besen, 2020-11-03 18:34

Subject: Re: git clean -Xdf doesn't clean ignored files in subfolders
Message-ID: <CAHqVHwv4BC-OnfCvXySvksGHCx_+URQedz-BT6CqGbndDTM8Tw@mail.gmail.com>
URL: https://gitlist.dev/e/CAHqVHwv4BC-OnfCvXySvksGHCx_%2BURQedz-BT6CqGbndDTM8Tw%40mail.gmail.com
In-Reply-To: <CABPp-BEF2wqP+Cx5-6yq6cfQ1Pa+8iOXWR11DNBH02yh-D8oFg@mail.gmail.com>

```
> Is this the same issue as reported at
> https://lore.kernel.org/git/4F1384AE.1050209@pcharlan.com/?

Yes, I believe so.  I am indeed using git clean as a substitute for make clean.

But, I still think a fix would be appropriate.  Ideally I could trust
git to remove all auto-generated files regardless of whether or not
the project even has a Makefile.

```

## Elijah Newren, 2020-11-03 19:14

Subject: Re: git clean -Xdf doesn't clean ignored files in subfolders
Message-ID: <CABPp-BHewkGXj41tLagMQ-DtdxqU2q=WpMqX+xziePtERt23MA@mail.gmail.com>
URL: https://gitlist.dev/e/CABPp-BHewkGXj41tLagMQ-DtdxqU2q%3DWpMqX%2BxziePtERt23MA%40mail.gmail.com
In-Reply-To: <CAHqVHwv4BC-OnfCvXySvksGHCx_+URQedz-BT6CqGbndDTM8Tw@mail.gmail.com>

```
On Tue, Nov 3, 2020 at 10:36 AM David Besen <dbesen@gmail.com> wrote:
>
> > Is this the same issue as reported at
> > https://lore.kernel.org/git/4F1384AE.1050209@pcharlan.com/?
>
> Yes, I believe so.  I am indeed using git clean as a substitute for make clean.
>
> But, I still think a fix would be appropriate.  Ideally I could trust
> git to remove all auto-generated files regardless of whether or not
> the project even has a Makefile.

I'm not trying to argue against a fix, just verifying that it wasn't
recent changes that might have caused problems, and linking the
reports together in the archive with a url to help anyone interested
be able to find them.

```
