{"thread":{"id":"29664","subject":"git clean is not removing a submodule added to a branch when switching branches","startedAt":"2012-02-18T21:27:42Z","lastAt":"2012-02-20T20:36:55Z","messageCount":2,"participants":["Adrian Cornish","Jens Lehmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"184936","messageId":"CAGc=MuDrE_1CVzOsqcodhadcfajaa-BHjHVAp9mFDNbU=wVQqQ@mail.gmail.com","threadId":"29664","inReplyTo":null,"subject":"git clean is not removing a submodule added to a branch when switching branches","fromName":"Adrian Cornish","fromEmail":"git@bluedreamer.com","sentAt":"2012-02-18T21:27:42Z","receivedAt":"2012-02-18T21:27:42Z","isPatch":false,"sender":{"key":"git@bluedreamer.com","avatar":null},"body":"If I add a submodule to a branch and then switch branches, git\ncheckout warns it cannot\nremove the submodule. If I then issue a git clean - it says it removes\nthe submodule but\nin fact does nothing at all. Is this a bug or expected behaviour.\n\nTIA\n\nAdrian\n\nBelow are cut&paste steps to reproduce.\n\ngit --version\n#git version 1.7.8.4\n\ngit init submod\ncd submod\necho \"This is a submodule\" > README.txt\ngit add .\ngit commit -m \"Initial commit\"\ncd ..\ngit init prog\ncd prog\necho \"This is a program\" > README.txt\ngit add .\ngit commit -a -m \"Initial commit\"\ngit checkout -b topic1\ngit submodule add ../submod\ngit commit -m \"Added submodule\"\n\ngit checkout master\n#warning: unable to rmdir submod: Directory not empty\n#Switched to branch 'master'\n\ngit status\n# On branch master\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#       submod/\n#nothing added to commit but untracked files present (use \"git add\" to track)\n\ngit clean -fd\n#Removing submod/\n\ngit status\n# On branch master\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n#\n#       submod/\n#nothing added to commit but untracked files present (use \"git add\" to track)\n"},{"id":"185021","messageId":"4F42AEE7.9060103@web.de","threadId":"29664","inReplyTo":"CAGc=MuDrE_1CVzOsqcodhadcfajaa-BHjHVAp9mFDNbU=wVQqQ@mail.gmail.com","subject":"Re: git clean is not removing a submodule added to a branch when switching branches","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-02-20T20:36:55Z","receivedAt":"2012-02-20T20:36:55Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 18.02.2012 22:27, schrieb Adrian Cornish:\n> If I add a submodule to a branch and then switch branches, git\n> checkout warns it cannot\n> remove the submodule. If I then issue a git clean - it says it removes\n> the submodule but\n> in fact does nothing at all. Is this a bug or expected behaviour.\n\nRight this is just how things work. I won't call it expected behavior,\nas some users (like you) would expect to see the submodule be removed\n(while others are used to the current behavior that submodule work\ntrees are never touched).\n\nBut one of last years GSoC projects took first steps into the\ndirection of safely removing submodules (without losing any history).\nI have experimental code at my Github repo [1] to update submodule\nwork trees along with the superproject, but polishing that for\ninclusion into mainline will still take some time.\n\n[1] https://github.com/jlehmann/git-submod-enhancements\n"}]}