Skip to content

Instantly share code, notes, and snippets.

@stufield
Last active May 26, 2023 19:15
Show Gist options
  • Save stufield/a2450fad4a370dce976639b0525855b9 to your computer and use it in GitHub Desktop.
Save stufield/a2450fad4a370dce976639b0525855b9 to your computer and use it in GitHub Desktop.
Removing a Git Submodule

Removing a Git Submodule

Removing a submodule is useful when no longer required, follow the steps below:

  • Delete the section referring to the submodule from the .gitmodules file
  • Stage the changes via:
git add .gitmodules
  • Delete the relevant section of the submodule from .git/config
  • Run:
git rm --cached path/to/submodule
  • Run:
rm -rf .git/modules/path/to/submodule
  • Commit the changes:
git commit -m "Removed Submodule"
  • Delete the now untracked dangling submodule files
rm -rf path/to/submodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment