Subject: Re: git submodule remove?

From: Raman Gupta <[email-masked]>
Date: Wed, 08 Jul 2009 17:54:04 -0400

Tim Henigan wrote:
> The Git Submodule Tutorial [2] has instructions for removing submodules, but it
> seems natural to teach git how to "submodule rm".

I'd like to see this as well.

> 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.

I'm not sure it should be removed from .git/config, and the untracked
files, automatically. If the module is only being removed on one
branch, then switching back to another branch will require the module
to be initialized again. Of course, then the user has to deal with
untracked files and to remember to prune entries from .git/config once
no more branches refer to them.

This is also a problem when renaming modules -- I always end up having
at least two entries in .git/config -- one for the branches using the
old name and one for the branches using the new name.

Perhaps one way to refactor submodule support in .git/config would be
to allow .git/config to specify search/replace expressions (simple or
regex-based) that would apply to the entries in .gitmodules. Most of
the time, a few simple expressions should be sufficient to cover all
of the necessary local settings.

Another possible useful change/addition would be to move the submodule
files in and out of the superproject (perhaps to/from a holding area
in superproject/.git) as the user switches their working copy between
branches that contain or do not contain specific submodules.

Cheers,
Raman Gupta