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

[BUG] git clean -d is too greedy

From
HSHermanni Suominen <hermanni@foobar.fi>
Date
Nov 2, 2017, 17:13 UTC
Message-ID
<d2e823e2-800d-17ba-c9d4-f490cefefd2f@foobar.fi>
Hi all,

Since commit 6b1db4310 it is possible to make git clean -d to remove nested git repositories if

   1) .gitignore exists in nested repo (either tracked or untracked)
   2) .gitignore is excluded

Regarding to 2) it doesn't matter if .gitignore is excluded from (another) .gitignore or from command-line (but I assume they populate same ignore list so that's just stating the obvious).

To demonstrate this I can run the following commands:

# git init -q foo && cd foo # git init -q bar && cd bar # touch .gitignore bar # git add bar && git commit -qm asd && cd .. # git clean -e .gitignore -dn Would remove bar/bar

Pre 6b1db4310, and if .gitignore isn't exclued, nested repo is correctly skipped:

# git clean -dn Would skip repository bar/

It probably isn't very common use case to exclude .gitignore but nevertheless this has been broken for a while, and to make things worse it can wipe out lots of uncommitted changes.

-- 
Hermanni
Next: Hermanni Suominen
Message 1 of 2 in “[BUG] git clean -d is too greedy”
  1. Hermanni SuominenNov 2, 2017
  2. Hermanni SuominenNov 2, 2017

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.