# Feat. req.: add a flag to `git clean` to also remove ignored nested repositories

3 messages from 2026-01-09 to 2026-01-16. Participants: Simon Cheng, brian m. carlson.
Thread: https://gitlist.dev/t/64761

## Simon Cheng, 2026-01-09 03:50

Subject: Feat. req.: add a flag to `git clean` to also remove ignored nested repositories
Message-ID: <CA+itcS3-RQ=ESqcWj0Pkw=N4e4gwaz2fp2xH2M1MPXQXaMDmCw@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BitcS3-RQ%3DESqcWj0Pkw%3DN4e4gwaz2fp2xH2M1MPXQXaMDmCw%40mail.gmail.com

```
Currently, running `git clean -dxf` on a repository that includes
another repository under an ignored path would skip said repository:

$ git clean -dxf
Removing foo
Skipping repository ignored-path/repo
Removing bar

This is to request the addition of a new flag to allow altering this
behaviour, i.e. to make `git clean` remove those repositories too.

For me, this feature is relevant for building `*-git` packages from
the AUR, for example https://aur.archlinux.org/packages/paru-git. By
default `makepkg` would clone the source repo into `./src/NAME`, which
creates the aforementioned condition. Without such an option on `git
clean`, cleanup after build is rather complicated.

Thanks and regards,
Simon Cheng

```

## brian m. carlson, 2026-01-09 13:18

Subject: Re: Feat. req.: add a flag to `git clean` to also remove ignored nested repositories
Message-ID: <aWEAHQLzwTxCpD5Q@fruit.crustytoothpaste.net>
URL: https://gitlist.dev/e/aWEAHQLzwTxCpD5Q%40fruit.crustytoothpaste.net
In-Reply-To: <CA+itcS3-RQ=ESqcWj0Pkw=N4e4gwaz2fp2xH2M1MPXQXaMDmCw@mail.gmail.com>

```
On 2026-01-09 at 03:50:30, Simon Cheng wrote:
> Currently, running `git clean -dxf` on a repository that includes
> another repository under an ignored path would skip said repository:
> 
> $ git clean -dxf
> Removing foo
> Skipping repository ignored-path/repo
> Removing bar
> 
> This is to request the addition of a new flag to allow altering this
> behaviour, i.e. to make `git clean` remove those repositories too.
> 
> For me, this feature is relevant for building `*-git` packages from
> the AUR, for example https://aur.archlinux.org/packages/paru-git. By
> default `makepkg` would clone the source repo into `./src/NAME`, which
> creates the aforementioned condition. Without such an option on `git
> clean`, cleanup after build is rather complicated.

Does this work if you use `git clean -dxff` (that is, with a second `-f`
flag)?  I do often clean up ignored repositories that way (and it's
documented to do that in the manual page), but I'm not sure if you're
maybe doing something a little different from my workflow.

If that _doesn't_ work for you, would you mind creating a quick shell
script to demonstrate the problem that you're seeing so that we could
provide better advice?
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

```

## Simon Cheng, 2026-01-16 05:16

Subject: Re: Feat. req.: add a flag to `git clean` to also remove ignored nested repositories
Message-ID: <CA+itcS3S3SXWGSwFp=k=f0u+q5eEqSqKMzFwLzKHLzLOtYpH9g@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BitcS3S3SXWGSwFp%3Dk%3Df0u%2Bq5eEqSqKMzFwLzKHLzLOtYpH9g%40mail.gmail.com
In-Reply-To: <aWEAHQLzwTxCpD5Q@fruit.crustytoothpaste.net>

```
Ah yes that's exactly what I need, thanks a lot. Pebkac moment for me sorry.

I must say though, the discoverability of this "double -f" behaviour
can be improved. Maybe the "nested repository skipped" message can
include a hint? Something like this I imagine:

Skipping repository ignored-path/repo (pass a second `-f` to remove)

Wdyt?

On Fri, 9 Jan 2026 at 21:18, brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> On 2026-01-09 at 03:50:30, Simon Cheng wrote:
> > Currently, running `git clean -dxf` on a repository that includes
> > another repository under an ignored path would skip said repository:
> >
> > $ git clean -dxf
> > Removing foo
> > Skipping repository ignored-path/repo
> > Removing bar
> >
> > This is to request the addition of a new flag to allow altering this
> > behaviour, i.e. to make `git clean` remove those repositories too.
> >
> > For me, this feature is relevant for building `*-git` packages from
> > the AUR, for example https://aur.archlinux.org/packages/paru-git. By
> > default `makepkg` would clone the source repo into `./src/NAME`, which
> > creates the aforementioned condition. Without such an option on `git
> > clean`, cleanup after build is rather complicated.
>
> Does this work if you use `git clean -dxff` (that is, with a second `-f`
> flag)?  I do often clean up ignored repositories that way (and it's
> documented to do that in the manual page), but I'm not sure if you're
> maybe doing something a little different from my workflow.
>
> If that _doesn't_ work for you, would you mind creating a quick shell
> script to demonstrate the problem that you're seeing so that we could
> provide better advice?
> --
> brian m. carlson (they/them)
> Toronto, Ontario, CA

```
