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

[BUG] git clean does not remove certain directories

From
SBSoren Brinkmann <soren.brinkmann@xilinx.com>
Date
Nov 21, 2012, 00:05 UTC
Message-ID
<933d806a-abce-4baf-8c3b-9b6742cb8ac7@VA3EHSMHS004.ehs.local>
Hi,
this use case may be a little awkward but this is the behavior I see:

I have a repository which has a couple of untracked directories which can also include git repositories. No submodules, though. I used 'git clean -xdf' on the top level of this repo to remove everything untracked in it - including the git repositories in sub-directories.

Since using git 1.8.0 the clean operation seems to be 'broken', as output indicates all those questionable sub directories are removed - just as in prior git versions - but in fact they remain untouched and are _not_ removed.

I attached a shell script creating a hierarchy to reproduce the issue. Executing the script creates the git repo 'repo.git' with a couple of tracked and untracked dirs/files and two more git repositories within the first one.

If you cd into repo.git and execute 'git clean -xdf' I see the following output:
	Removing repo2.git/
	Removing untracked_dir/

But the directories remain intact when using git 1.8.0. With git 1.6.3.2 it works as I expected and removes the directories. I'm pretty sure the 1.7.x versions did the same, but it's no longer installed here.

I can see that this behavior may partially be intended, but the tool output should match its actions. So, either the directories should be removed, or the output should state, that they are not removed for what reason whatsoever, IMHO

	Thanks,
	Soren

#!/bin/sh mkdir repo.git cd repo.git git init echo foo > tracked_file1 git add tracked_file1 mkdir tracked_dir echo foo > tracked_dir/tracked_file2 git add tracked_dir/tracked_file2 git commit -m "Adding tracked files" mkdir repo2.git echo foo > repo2.git/tracked_file3 mkdir -p untracked_dir/repo3.git echo foo > untracked_dir/repo3.git/tracked_file4 cd repo2.git git init git add tracked_file3 git commit -m "Adding file to subrepo1" cd ../untracked_dir/repo3.git git init git add tracked_file4 git commit -m "Adding file to subrepo2" cd ../..

Next: Soren Brinkmann
Message 1 of 2 in “[BUG] git clean does not remove certain directories”
  1. Soren BrinkmannNov 21, 2012
  2. Soren BrinkmannNov 21, 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.