Re: git clean --exclude broken?
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Nov 28, 2024, 20:58 UTC
- Message-ID
- <Z0jZfltm0O3y9QoW@tapette.crustytoothpaste.net>
- In-Reply-To
- <CABAKogYaajvedff2ihsC5g+156L-Oe2N_XR3c+uyyfoovVQ5gg@mail.gmail.com>
On 2024-11-26 at 06:13:44, Homyee King wrote:
Show 14 quoted lines
> Thanks for replying. > It's a typo mistake, the correct command is `git clean -Xdn -e foo` but the > problem still exists which is `--exclude` option not work with `-X`, is > that design so or a bug? For example: > > simple-project/ │ ├── foo/ │ > |---- bar/ ├── .gitignore # contains foo/ bar/ │ └── test.ts # untracked > file > > I only want to clear all gitignored files/folder but *`foo/` *and keep the > untrakced files/folders, so here's the command > $ git clean -Xdn -e foo > $ ls > $ Would remove foo/ bar/
I don't think there's a command for what you want to do here. You basically want to clear only ignored files, but exclude one pattern from the ignore rules. `-e` doesn't do that: it _adds_ to the ignore rules, not subtracts from them.
So this is what I'd expect to see here with your file structure:
---- % git clean -Xdn -e test.ts Would remove bar/ Would remove foo/ Would remove test.ts ----
since by using `-e`, we've added the additional files to be ignored, and with `-X`, we've said to remove the files.
-- brian m. carlson (they/them or he/him) Toronto, Ontario, CA