threads / discuss / 54558

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

Subject: git clean -Xdf doesn't clean ignored files in subfolders

## tl;dr

4 messages between Nov 2, 2020 and Nov 3, 2020.

replies: 3people: 2as markdown or json

David Besen· Nov 2, 2020, 22:44 UTC · lore
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· Nov 3, 2020, 17:11 UTC · re: David Besen · lore

Re: git clean -Xdf doesn't clean ignored files in subfolders

On Mon, Nov 2, 2020 at 2:46 PM David Besen <dbesen@gmail.com> wrote:
Show 17 quoted lines
>
> 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· Nov 3, 2020, 18:34 UTC · re: Elijah Newren · lore

Re: git clean -Xdf doesn't clean ignored files in subfolders

> 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· Nov 3, 2020, 19:14 UTC · re: David Besen · lore

Re: git clean -Xdf doesn't clean ignored files in subfolders

On Tue, Nov 3, 2020 at 10:36 AM David Besen <dbesen@gmail.com> wrote:
Show 9 quoted lines
>
> > 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.

← back to recent threads