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

git clean removes directories when not asked to

From
JHJoachim B Haga <jobh@broadpark.no>
Date
Apr 8, 2008, 18:22 UTC
Message-ID
<85prt0jjen.fsf@lupus.strangled.net>
This is with debian packaged 1.5.4.4.

When invoked from a subdirectory, git clean removes more than it should. According to the documentation, it should not remove directories unless "-d" is given. However:

pep ~/src/test 0$ git init Initialized empty Git repository in .git/ pep ~/src/test|master 0$ mkdir dir pep ~/src/test|master 0$ mkdir dir/subdir pep ~/src/test|master 0$ git clean -f Not removing dir/ pep ~/src/test|master 0$ cd dir pep ~/src/test/dir|master 0$ git clean -f Removing subdir/ pep ~/src/test/dir|master 0$ ls subdir ls: cannot access subdir: No such file or directory

Luckily I just lost some compilation results in this case, but this is unexpected and dangerous behaviour.

(Additionally, I find the "-f" slightly annoying but that's not an issue here.)
-j
Next: Joachim B Haga
Message 1 of 14 in “git clean removes directories when not asked to”
  1. Joachim B HagaApr 8, 2008
  2. Joachim B HagaApr 8, 2008
  3. Re: git clean removes directories when not asked toJoachim B Haga, Apr 9, 2008
  4. git clean: Don't automatically remove directories when run within subdirectoryShawn Bohrer, Apr 13, 2008
  5. git clean: Add test to verify directories aren't removed with a prefixShawn Bohrer, Apr 13, 2008
  6. Joachim Berdal HagaApr 14, 2008
  7. Junio C HamanoApr 14, 2008
  8. Shawn BohrerApr 14, 2008
  9. Joachim Berdal HagaApr 14, 2008
  10. Shawn BohrerApr 15, 2008
  11. Joachim Berdal HagaApr 15, 2008
  12. Shawn BohrerApr 15, 2008
  13. Joachim Berdal HagaApr 15, 2008
  14. git clean: Don't automatically remove directories when run within subdirectoryShawn Bohrer, Apr 15, 2008

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.