Last Updated: January 02, 2023
·
84.53K
· santiagogil

Remove a git submodule

To remove a submodule you need to:

  • Delete the relevant line from the .gitmodules file.
  • Delete the relevant section from .git/config.
  • Run git rm --cached pathtosubmodule (no trailing slash).
  • Commit the superproject.
  • Delete the now untracked submodule files.

Source(s): GitSubmoduleTutorial : https://git.wiki.kernel.org/index.php/GitSubmoduleTutorial

Must find a simpler way...

Related protips:

git checkout remote branch

6 Responses
Add your response

I didn't found other way. It's the only.
You can write script to do it.

over 1 year ago ·

There is a topic-branch in git.git for git-submodule-rm, http://comments.gmane.org/gmane.comp.version-control.git/209755

over 1 year ago ·

@mindjiver Intresting. Thanks!

over 1 year ago ·

Why subprojects have to be so difficult...

over 1 year ago ·

Instead of manually editing .git/config, I think that git submodule deinit can be used more easily.

over 1 year ago ·

Thanks for the clear explanation of the steps

over 1 year ago ·