News Stay informed about the latest enterprise technology news and product updates.

How to remove Git submodules

Steps to delete a Git submodule

The manner in which you remove a Git submodule has changed since earlier versions of the tool, so there is a significant amount of erroneous data about how to do a git submodule delete. But the fact is, there are a few simple steps to remove git submodules:

  1. Remove the submodule with the git rm command.
  2. Remove the associated submodule folder under .git/modules.
  3. Delete the reference to the removed git submodule from .git/config.
  4. Push your changes to GitHub or GitLab.

Removing Git submodules completely is a three-step process.

Git submodule remove example

The commands used in the Git submodule delete example are as follows:

[email protected]:~$ git rm submarines
[email protected]:~$ rm -rf .git/modules/submarines
[email protected]:~$ git config -f .git/config --remove-section submodule.submarine 2> /dev/null
[email protected]:~$ git add .
[email protected]:~$ git commit -m "git remove submodule example complete"
[email protected]:~$ git push origin

Git submodule delete and removal is typically the last step when working with submodules. To learn more about how to work with submodules, including how to update, create and clone submodule repositories.

SearchAppArchitecture
SearchSoftwareQuality
SearchCloudComputing
SearchSecurity
SearchAWS
Close