About this question
How do you properly remove a Git submodule from your repository? What steps are required to clean up its configuration and files completely?
How do you properly remove a Git submodule from your repository? What steps are required to clean up its configuration and files completely?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask DevOps Expert
Answered on Aug 26, 2025
When working with Git repositories, you might add a submodule for dependency management, but later realize you don’t need it anymore. This raises the question: “How do I remove a submodule cleanly?” Simply deleting the folder isn’t enough—you also need to remove its configuration and references.
Step 1: Deinitialize the Submodule
Run the following command to remove the submodule from Git’s configuration:
git submodule deinit -f path/to/submoduleStep 2: Remove from Index
Next, remove the submodule entry from the Git index (staging area):
git rm -f path/to/submodule This deletes the submodule directory and stages the removal for commit.
Step 3: Delete Submodule Files
Git stores submodule data in the .git/modules directory. To remove it completely:
rm -rf .git/modules/path/to/submoduleStep 4: Commit the Changes
Finally, commit the removal so the repository no longer tracks the submodule:
git commit -m "Removed submodule path/to/submodule" Key Takeaway:
To fully remove a submodule, you must (1) deinitialize it, (2) remove it from the index, (3) delete its module data, and (4) commit the changes. Skipping these steps may leave behind hidden configuration files that can cause issues later.
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Most-read guides across JanBask
Common DevOps interview questions, answered
Guides, tips and career advice on DevOps from JanBask experts.
DevOps How to Become a DevOps Engineers: Learning Path, Critical skills & More
Looking for answer to how to become a DevOps engineer in 2025? Here is the detailed article about DevOps career path, DevOps…
DevOps Top 50+ Jenkins Interview Questions And Answers For 2025
Here are the Top 50 Jenkins interview questions frequently asked in top MNCs which will help you land an ideal job! These…
DevOps Best 37 DevOps Tools To Learn And Master In 2025: Docker, Git & More
Want to know what are Devops tools and their uses? Or looking for the best DevOps list for automation, monitoring, & development?…
DevOps DevOps Engineer Job Description: Roles and Responsibilities [2025 Updated]
Discover the essential roles and responsibilities of a DevOps Engineer by exploring the detailed DevOps job description, and…