Skip to content

Instantly share code, notes, and snippets.

@ssrlive
Created August 25, 2021 02:42
Show Gist options
  • Save ssrlive/97ca3ad2c3bdeaeca5f6174f6007ef22 to your computer and use it in GitHub Desktop.
Save ssrlive/97ca3ad2c3bdeaeca5f6174f6007ef22 to your computer and use it in GitHub Desktop.
How to remove a submodule of git

How to remove a submodule you need to:

  • Run git rm --cached path_to_submodule (no trailing slash).
  • Delete the now untracked submodule files by run rm -rf path_to_submodule
  • Run rm -rf .git/modules/path_to_submodule
  • Delete the relevant section from the .gitmodules file.
  • Delete the relevant section from .git/config.
  • Stage the .gitmodules changes git add .gitmodules
  • Commit git commit -m "Removed submodule <name>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment