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

Re: git submodule remove?

From
Tim Harper <timcharper@gmail.com>
Date
Jul 11, 2009, 05:27 UTC
Message-ID
<e1a5e9a00907102227y4ea2b1f6y2e9882afd726a4eb@mail.gmail.com>
In-Reply-To
<32c343770907081241h5925545ah1cb551b31e45ddc0@mail.gmail.com>
On Wed, Jul 8, 2009 at 1:41 PM, Tim Henigan<tim.henigan@gmail.com> wrote:
Show 15 quoted lines
> Hello,
>
> I recently encountered a situation where a user wanted to remove a submodule
> from a repository.  Searching the mail archive, I found this thread
> [1], but it does
> not appear that it was ever followed up.
>
> The Git Submodule Tutorial [2] has instructions for removing submodules, but it
> seems natural to teach git how to "submodule rm".
>
> This change would require git-submodule.sh to:
>    1. Modify the .gitmodules file (remove the entry for the submodule).
>    2. Modify the .git/config file (remove the entry for the submodule).
>    3. Delete the newly untracked files.
>

Submodules are tracked by the tree. You'll need to 'rm -rf' the submodule, and then 'git rm' the folder to remove it.

Show 8 quoted lines
> Another option to consider would be a "submodule rm --cached" option which would
> keep the newly untracked files.  However, with this option, I believe
> it should still
> descend into the submodule directory to remove the leftover submodule
> ".git" folder.
>
> Is there another way of doing this?  If not, does this sound like a
> reasonable change?

I can think of the only opposition being how blatantly dangerous it would be. You're creating a command that will nuke the whole repository, along with any unpushed changes. There's potential there for someone to seriously injure themselves without realizing it.

There's also the issue of once you delete a submodule... now what? Git won't automatically remove them from other repositories when the change gets pulled. The folder will show up as untracked. So far the current paradigm with git submodules is git is very "hands off" and leaves as much as possible to you. I think we would have to see a change in thought consistently around how to approach submodules before git implements anything of this sort.

Previous: Raman Gupta
Message 3 of 3 in “git submodule remove?”
  1. Tim HeniganJul 8, 2009
  2. Raman GuptaJul 8, 2009
  3. Tim HarperJul 11, 2009

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.