Skip to content

Instantly share code, notes, and snippets.

@joeyates
Last active August 29, 2015 14:04
Show Gist options
  • Save joeyates/6f1bd6e12eae4cce6d12 to your computer and use it in GitHub Desktop.
Save joeyates/6f1bd6e12eae4cce6d12 to your computer and use it in GitHub Desktop.
Removing submodules

Based on

Delete the relevant section from .git/config:

git config -f .git/config --remove-section submodule.SUBMODULE_NAME

Delete the relevant section from the .gitmodules file:

git config -f .gitmodules --remove-section submodule.SUBMODULE_NAME

Stage the .gitmodules changes:

git add .gitmodules

Stage removal of the submodule:

git rm --cached path/to/submodule # N.B. no trailing slash

Remove files from the file system:

rm -rf .git/modules/path/to/submodule

Commit changes:

git commit -m 'Removed submodule SUBMODULE_NAME'

Delete the now untracked 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