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

git clean is not removing a submodule added to a branch when switching branches

From
ACAdrian Cornish <git@bluedreamer.com>
Date
Feb 18, 2012, 21:27 UTC
Message-ID
<CAGc=MuDrE_1CVzOsqcodhadcfajaa-BHjHVAp9mFDNbU=wVQqQ@mail.gmail.com>

If I add a submodule to a branch and then switch branches, git checkout warns it cannot remove the submodule. If I then issue a git clean - it says it removes the submodule but in fact does nothing at all. Is this a bug or expected behaviour.

TIA
Adrian
Below are cut&paste steps to reproduce.

git --version #git version 1.7.8.4

git init submod cd submod echo "This is a submodule" > README.txt git add . git commit -m "Initial commit" cd .. git init prog cd prog echo "This is a program" > README.txt git add . git commit -a -m "Initial commit" git checkout -b topic1 git submodule add ../submod git commit -m "Added submodule"

git checkout master #warning: unable to rmdir submod: Directory not empty #Switched to branch 'master'

git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # submod/ #nothing added to commit but untracked files present (use "git add" to track)

git clean -fd #Removing submod/

git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # submod/ #nothing added to commit but untracked files present (use "git add" to track)

Next: Jens Lehmann
Message 1 of 2 in “git clean is not removing a submodule added to a branch when switching branches”
  1. Adrian CornishFeb 18, 2012
  2. Jens LehmannFeb 20, 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.