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

Unexpected "clean -Xd" behavior

From
PHPete Harlan <pgit@pcharlan.com>
Date
Jan 16, 2012, 02:00 UTC
Message-ID
<4F1384AE.1050209@pcharlan.com>
Hi,

When a directory contains nothing but an ignored subdirectory, that subdirectory does not get removed by "git clean -Xdf".

For example, in a new directory:
# git init
Initialized empty Git repository in /tmp/foo/.git/
# echo a/ >.gitignore
# git add .gitignore
# git commit -m "Initial commit"
[master (root-commit) c3af24c] Initial commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
# mkdir -p foo/a
# touch foo/a/junk.o
# git status
# On branch master
nothing to commit (working directory clean)
# git clean -Xdn  # <--- DOES NOT MENTION foo/a
# touch foo/x.c
# git clean -Xdn  # <--- DITTO WITH UNTRACKED IN foo
# git add foo/x.c
# git clean -Xdn  # <--- WITH TRACKED IN foo, WILL REMOVE a/
Would remove foo/a/
#

Is this intentional? It's interfering with my using "git clean" to remove built objects, which happen to be in a dedicated temporary subdirectory.

Thanks,
--Pete Harlan
  pgit@pcharlan.com
Next: Jonathan Nieder
Message 1 of 5 in “Unexpected "clean -Xd" behavior”
  1. Pete HarlanJan 16, 2012
  2. Jonathan NiederJan 19, 2012
  3. Nguyen Thai Ngoc DuyJan 19, 2012
  4. Jonathan NiederJan 19, 2012
  5. pgit@pcharlan.comJan 19, 2012

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.