On 2024-11-26 at 06:13:44, Homyee King wrote: > 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
Attachment:
signature.asc
Description: PGP signature