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

git clean -X behaviour when .gitignore has sub-directory entries

From
Jean-Philippe Gariépy <jean-philippe.gariepy@nuecho.com>
Date
Jul 16, 2010, 19:05 UTC
Message-ID
<4C40AD89.1070005@nuecho.com>
Hi,

When using sub-directory entries in .gitignore, "git clean -X" doesn't clean the ignored sub-directory.

$ git init test
Initialized empty Git repository in /home/jpgariep/git/test/.git/
$ cd test/
$ mkdir -p a/b/c
$ touch a/b/c/test
$ echo '/a/b/' > .gitignore
$ git add .gitignore
$ git commit -m "Added .gitignore."
[master (root-commit) 94e2825] Added .gitignore.
  1 files changed, 1 insertions(+), 0 deletions(-)
  create mode 100644 .gitignore
$ git status
# On branch master
nothing to commit (working directory clean)
$ git clean -X -d -f
$ ls a
b
Why is b still there?
Thanks.
-- 
Jean-Philippe Gariépy
Message 1 of 1 in “git clean -X behaviour when .gitignore has sub-directory entries”
  1. Jean-Philippe GariépyJul 16, 2010

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.