{"thread":{"id":"39161","subject":"Cleaning projects with submodules","startedAt":"2015-04-25T21:36:25Z","lastAt":"2015-04-27T12:47:29Z","messageCount":2,"participants":["Simon Richter","Heiko Voigt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"260008","messageId":"553C08D9.9000907@hogyros.de","threadId":"39161","inReplyTo":null,"subject":"Cleaning projects with submodules","fromName":"Simon Richter","fromEmail":"simon.richter@hogyros.de","sentAt":"2015-04-25T21:36:25Z","receivedAt":"2015-04-25T21:36:25Z","isPatch":false,"sender":{"key":"simon.richter@hogyros.de","avatar":"https://gravatar.com/avatar/1192aa9fa5dd19ce258b12b044cc27111dd7cdb58d920dc2123a02a24f55b5c5?d=mp&s=160"},"body":"Hi,\n\nI'm trying to set up a continuous integration build for Boost, which\nuses massive amounts of submodules, and keep running into problems when\nrunning \"git clean\" in the toplevel project.\n\nWhen I switch to a version where a submodule has been removed (e.g. an\nearlier version), \"git clean -dx\" will not remove the submodule's\ndirectory, because it has its own .git directory. Using a single -f\nflag, the process fails (because directories containing .git directories\nare no longer skipped), and using -ff removes all submodules (which is\noverkill).\n\nIs there a good way to clean a project, leaving valid submodules in\nplace (these are then switched to the new tip and cleaned in separate\ncommands) while removing submodules that are no longer referenced?\n\n   Simon\n\n"},{"id":"260055","messageId":"20150427124729.GA5399@sandbox-ub1410","threadId":"39161","inReplyTo":"553C08D9.9000907@hogyros.de","subject":"Re: Cleaning projects with submodules","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2015-04-27T12:47:29Z","receivedAt":"2015-04-27T12:47:29Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Hi,\n\nOn Sat, Apr 25, 2015 at 11:36:25PM +0200, Simon Richter wrote:\n> I'm trying to set up a continuous integration build for Boost, which\n> uses massive amounts of submodules, and keep running into problems when\n> running \"git clean\" in the toplevel project.\n> \n> When I switch to a version where a submodule has been removed (e.g. an\n> earlier version), \"git clean -dx\" will not remove the submodule's\n> directory, because it has its own .git directory. Using a single -f\n> flag, the process fails (because directories containing .git directories\n> are no longer skipped), and using -ff removes all submodules (which is\n> overkill).\n> \n> Is there a good way to clean a project, leaving valid submodules in\n> place (these are then switched to the new tip and cleaned in separate\n> commands) while removing submodules that are no longer referenced?\n\nUnfortunately there is no really nice way for that yet. Safely removing\nsubmodule ist still under development.\n\nHere is a snippet that I used on a CI server for this purpose:\n\n   git status --porcelain | grep \"^?? \" | sed -e 's/^?? //' | \\\n   while read i; do\n        rm -rf \"$i\"\n   done\n\nIt does a little more, since it unconditionally removes all untracked files\nthat are not ignored.\n\nCheers Heiko\n"}]}