git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git clean --exclude broken?

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Dec 10, 2024, 02:23 UTC
Message-ID
<Z1emFS-L-f4caBJ1@tapette.crustytoothpaste.net>
In-Reply-To
<CABAKogZQ4bAh-KPE79q0W7iBBoRmxW26RK_6VSg=6Y-Sg68tig@mail.gmail.com>
On 2024-12-09 at 04:53:24, Homyee King wrote:
Show 5 quoted lines
> But if you try *git clean -xdn -e foo*, the *foo *will be excluded and not
> what you said *"it _adds_ to the ignore rules".  *It's the confusing part
> of *`-e` *option, and I think it should always exclude something within the
> given pattern.
> If we follow what you said, it should be *--include,* what do you think?

The `--exclude` option means "exclude this (mark this as ignored) additionally". I agree it could be misinterpreted, but `--include` could as well. The manual page says this about `-e`:

  Use the given exclude pattern in addition to the standard ignore rules
  (see gitignore(5)).
And the text says this about `-x`:
  Don’t use the standard ignore rules (see gitignore(5)), but still use
  the ignore rules given with -e options from the command line. This
  allows removing all untracked files, including build products. This
  can be used (possibly in conjunction with git restore or git reset) to
  create a pristine working directory to test a clean build.

That means that when you say `git clean -xdn -e foo`, Git ignores only `foo`, and says it will remove everything else that would normally be ignored (which is no longer ignored, and thus untracked). Remember that `git clean` only removes untracked files and directories, and `-x` just makes all files normally ignored untracked temporarily for the life of the command. Equivalent text exists in the description section of the manual page.

I don't think this is confusing or that the text is inaccurate, but of course if you want to submit a patch to improve the text, I'm sure we'd be happy to take a look.

-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
Previous: brian m. carlson
Message 4 of 4 in “git clean --exclude broken?”
  1. Homyee KingNov 24, 2024
  2. brian m. carlsonNov 24, 2024
  3. brian m. carlsonNov 28, 2024
  4. brian m. carlsonDec 10, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.