threads / discuss / 64937

git clean ignore

Subject: git clean ignore

## tl;dr

3 messages between Feb 7, 2026 and Feb 8, 2026.

replies: 2people: 3as markdown or json

Sylvain Rabot· Feb 7, 2026, 14:53 UTC · lore
Hi,
I'm a big user of git clean -fdx which is the shortest path to a clean worktree.

However, I repeatedly found myself deleting precious git ignored resources such as editor/debug configurations so I asked myself if the git ignore mechanism could be applied to git clean so that we can declare a list of patterns git clean should never remove.

I launched an AI agent on this and here is the result: https://github.com/sylr/git/commit/13d0177c52130782bcf7877895a5b497abdfba86

Since I'm no C developer I'm not really qualified to review the AI output but it seems to do what I wanted. I'm not expecting it to be merged but I am wondering if this is a feature git would be likely to implement ?

Regards.
-- 
Sylvain Rabot <sylvain@abstraction.fr>
Kristoffer Haugsbakk· Feb 7, 2026, 15:00 UTC · re: Sylvain Rabot · lore

Re: git clean ignore

On Sat, Feb 7, 2026, at 15:53, Sylvain Rabot wrote:
Show 9 quoted lines
> Hi,
>
> I'm a big user of git clean -fdx which is the shortest path to a clean worktree.
>
> However, I repeatedly found myself deleting precious git ignored
> resources such as editor/debug configurations so I asked myself if the
> git ignore mechanism could be applied to git clean so that we can
> declare a list of patterns git clean should never remove.
>[snip]
Related: https://lore.kernel.org/git/pull.1627.git.1703643931314.gitgitgadget@gmail.com/T/#u
D. Ben Knoble· Feb 8, 2026, 02:28 UTC · re: Sylvain Rabot · lore

Re: git clean ignore

On Sat, Feb 7, 2026 at 9:53 AM Sylvain Rabot <sylvain@abstraction.fr> wrote:
>
> Hi,
>
> I'm a big user of git clean -fdx which is the shortest path to a clean worktree.
If you can't drop -x for some reason, consider "git worktree add" ?
-- 
D. Ben Knoble

← back to recent threads