Git Submodule Remove 

The problem of git submodule remove 

In this blog, we will learn how a user can remove a submodule from git. Another name for the same problem is git submodule remove. The solution to this problem was quite difficult in the older versions of git. With the advancement in the versions of git, this task has also become much easier.

 

 

Solution

To solve the above problem in a new version of git one just needs to run the command as shown below: 

 

   Run git rm <path-to-submodule> 

 

After running the above command one should commit the changes in order to save them. This deletes both the entry for the submodule in the.gitmodules file as well as the file tree located at path-to-submodule>. In other words, the submodule is completely gone from your repository. 

Another stepwise procedure for the same is also shown here:

  1. From the.gitmodules file, remove the pertinent portion.
  2. Stage the modifications to the.gitmodules:

 

git add .gitmodules

      3. Delete the respective file from .git/config.

 

      4. Submodule files should be removed from the working tree and index:    

 

git rm –cached path_to_submodule

 

     5. Delete the.git directory for the submodule:

 

rm -rf .git/modules/path_to_submodule

 

     6. Save the changes by using the commit operation. 

 

git commit -m “Removed submodule <name>”

    7. Delete the files from the now-untracked submodule:

 

rm -rf path_to_submodule

 

 

 

Also Read: AlphaStar: Strategy game StarCraft II expertise

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *