{"thread":{"id":"66280","subject":"[RFC] git clean: add persistent exclude patterns","startedAt":"2026-09-06T13:56:49Z","lastAt":"2026-09-06T13:56:49Z","messageCount":1,"participants":["Nicolas Jeanmonod"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"552073","messageId":"CA+35gGbO4_Yy=vZ+nZSLBorRnZMyBsr-Okn+rh0yrXiEWy=BFg@mail.gmail.com","threadId":"66280","inReplyTo":null,"subject":"[RFC] git clean: add persistent exclude patterns","fromName":"Nicolas Jeanmonod","fromEmail":"nicolas.jeanmonod@gmail.com","sentAt":"2026-09-06T13:56:38Z","receivedAt":"2026-09-06T13:56:49Z","isPatch":false,"body":"Hi,\n\nI would like to propose a way to configure persistent exclusion\npatterns for `git clean`.\n\nCurrently, `git clean` supports:\n\n```\n-e <pattern>\n--exclude=<pattern>\n```\n\nand these exclusions are deliberately still honored when `-x` is used.\n\nFor example:\n\n```\ngit clean -fdx -e '*nogitclean*'\n```\n\nwill remove ignored files while preserving paths matching `*nogitclean*`.\n\nWhat seems to be missing is a way to make such exclusions persistent.\nA possible configuration could be:\n\n```\n[clean]\n    exclude = *nogitclean*\n```\n\nor, for multiple patterns:\n\n```\n[clean]\n    exclude = *nogitclean*\n    exclude = important-local-data/\n```\n\nwhich could be configured globally or per repository:\n\n```\ngit config --global --add clean.exclude '*nogitclean*'\n```\n\nThe intended semantics would be the same as if the configured patterns\nhad been supplied using `git clean -e`: in particular, they would\ncontinue to protect matching paths when `git clean -x` is used.\n\nThe use case is slightly different from `.gitignore` or\n`core.excludesFile`. Those answer the question \"which files should Git\nnormally ignore?\", whereas this configuration would answer \"which\nuntracked paths should `git clean` never remove by default, even when\ncleaning ignored files?\"\n\nOne concrete use case is keeping local metadata or other irreplaceable\ndirectories inside a working tree while still being able to use `git\nclean -fdx` for build products. Such directories may intentionally be\nignored by Git, but `-x` currently removes them unless the\ncorresponding `-e` option is remembered every time.\n\nAn alternative design could be a dedicated file such as\n`clean.excludesFile`, but a multi-valued `clean.exclude` setting seems\nsimpler and maps directly to the existing `-e` option.\n\nWould such a configuration be considered useful and consistent with\nthe intended semantics of `git clean`?\n\nThanks,\nNicolas\n"}]}