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. The fact is, there are just 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

To remove git submodules completely is a three step process.

git submodule remove example

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

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

The git submodule delete and removal  is typically the last step in working with submodules. To learn more about how to work with submodules, including how to update, create and clone submodule repositories, take a look at our ‘git submodule how to‘ tutorials.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchAppArchitecture

SearchSoftwareQuality

SearchCloudComputing

SearchSecurity

SearchAWS

Close