Skip to content

Instantly share code, notes, and snippets.

@yinsyim
Last active September 20, 2019 08:09
Show Gist options
  • Select an option

  • Save yinsyim/982400b47c2e2e0b5e044e23cbd31ced to your computer and use it in GitHub Desktop.

Select an option

Save yinsyim/982400b47c2e2e0b5e044e23cbd31ced to your computer and use it in GitHub Desktop.
delete a git submodule, since git 1.8.5.2

delete a git submodule, since git 1.8.5.2

from stackoverflow


# git rm the_submodule
# rm -rf .git/modules/the_submodule

If the second line isn't used, even if you removed the submodule for now, the remnant .git/modules/the_submodule folder will prevent the same submodule from being added back or replaced in the future. Also, git rm will do most of the job on a submodule.


The two commands (although functionally sufficient to remove a submodule), do leave a trace in the [submodule "the_submodule"] section of .git/config (as of July 2017), which can be removed using a third command:

# git config -f .git/config --remove-section submodule.the_submodule 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment