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

Re: [RFH] "git clean" deletes excluded files in untracked directories

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 22, 2014, 21:39 UTC
Message-ID
<xmqq8unlf4z4.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140702191114.GA3474@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 10 quoted lines
> If you have an untracked directory that contains excluded files, like
> this:
>
>   mkdir foo
>   echo content >foo/one
>   echo content >foo/two
>   echo "foo/one" >.gitignore
>
> then "git clean -d" will notice that "foo" is untracked and recursively
> delete it and its contents, including the ignored "foo/one".

Hmph, starting from an empty repository and doing the above four commands, and "git clean" without "-d" does not bother removing either foo/one or foo/two. Is this correct?

It gets worse.  Following the above four commands and then these two:
    >foo/three
    git add foo/two

and "git clean" (with or without "-d") suddenly notices that "foo/three" is expendable, but not foo/one nor foo/two, which sounds about right.

Honestly, as I do not use "git clean" myself, I do not know what the "right" behaviour is for that command. Anything it does seems just arbitrary and wrong to me ;-)

Previous: Jeff KingNext: Junio C Hamano
Message 7 of 8 in “t7300: repair filesystem permissions with test_when_finished”
  1. t7300: repair filesystem permissions with test_when_finishedJeff King, Jul 2, 2014
  2. Jonathan NiederJul 2, 2014
  3. Jeff KingJul 2, 2014
  4. Junio C HamanoJul 2, 2014
  5. Junio C HamanoJul 2, 2014
  6. [RFH] "git clean" deletes excluded files in untracked directoriesJeff King, Jul 2, 2014
  7. Junio C HamanoJul 22, 2014
  8. Junio C HamanoJul 22, 2014

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.