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

Accidentially deleted directory, bug in git clean -d?

From
RPRobin Pedersen <robinp@snap.tv>
Date
Mar 10, 2014, 10:31 UTC
Message-ID
<CABN9-fcpyDogh45WPwuS1qgkE1jLuOAtejuW=fGCKNNyNm3DEQ@mail.gmail.com>

I accidentially deleted a directory using git clean. I would think this is a bug, but I'm not sure. Was using 1.8.1, but upgraded to 1.9.0 just to see if it was still reproducable, and it was.

Here's a minimal way to reproduce:

$ git init $ mkdir foo foobar $ git clean -df foobar Removing foo/ Removing foobar/ $ ls $

I expected only "foobar" to be deleted, but "foo" was also deleted.
The same thing happens in the opposite case:

$ git init $ mkdir foo foobar $ git clean -df foo Removing foo/ Removing foobar/ $ ls $

However, it only happens when there is a common prefix in the names:

$ git init $ mkdir foo bar $ git clean -df foo Removing foo/ $ ls bar $

In this case, "bar" was not deleted.
-- 
Best regards,

Robin Pedersen
Software Engineer

SnapTV AS
Jordmor Magdalenes vei 17
N-9519 Kviby.
Norway

robinp@snap.tv
http://www.snap.tv
Next: Jeff King
Message 1 of 6 in “Accidentially deleted directory, bug in git clean -d?”
  1. Robin PedersenMar 10, 2014
  2. clean: respect pathspecs with "-d"Jeff King, Mar 10, 2014
  3. Jeff KingMar 10, 2014
  4. Simon RuderichMar 10, 2014
  5. Jeff KingMar 10, 2014
  6. clean: simplify dir/not-dir logicJeff King, Mar 10, 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.