How to effectively and completely delete a git submodule
William L'Archeveque

William L'Archeveque @wlarch

About: Full-Stack Devops & Web Developer. Enthusiast Helper. Freelancer for 7 years, now having fun working at Centiva. Specialized in Laravel PHP, AWS Cloud and cartwheeling.

Location:
Montréal, QC
Joined:
Dec 17, 2020

How to effectively and completely delete a git submodule

Publish Date: Jan 25 '21
0 0

I have been working on multiple projects included as Git submodules in a parent repository. Recently, I had to remove one project that we did not need anymore.

Side note : This parent repository is used to easily clone multiple projects in the same directory for new employees at our startup. The different projects are linked together and interact to each other as their code is executed in separate Docker containers.

Example project structure :

|- blog_main
    |- blog_api
    |- blog_frontend
    |- local_dev_infrastructure
Enter fullscreen mode Exit fullscreen mode

Here is the way I could remove a submodule and commit the changes to the parent directory.

git submodule deinit <path_to_submodule>
git rm <path_to_submodule>
git commit -m "Removed submodule"
rm -rf .git/modules/<path_to_submodule>
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment