

Url = 4: Remove the relevant directory from. git/config file and delete the section related to your submodule. Url = 3: Delete the relevant section from. gitmodules file and delete the section related to your submodule. Step 2: Delete the relevant lines from the. If you haven't already, remove the submodule from the cache using the git rm -cached command.Īlso, remove the submodule directory using rm -rf. Step 1: Remove the submodule from the cache and the disk In order to fix this, there are 5 steps you have to do to get your submodules working again.įor this example, I'm going to use src/content as the path to the submodule and as the git repository URL. Git gets confused because it expects the directory to be empty when adding a new submodule. This error typically happens when there's already a '.git' directory present in the directory where you're trying to add the submodule. Instead of adding the repository as a submodule, Git responds with a error message: "a git directory is found locally, rm the '.git' file in to clone." Understanding the Issue You may encounter this issue while trying to add a submodule to your repository using the command: git submodule add So, let's dive right into it! The Problem
#Git submodule add example how to
This blog post aims to help you learn about why this problem occurs and how to fix it effectively. In this blog post, we're going to demystify this error message and provide a step-by-step solution to get you back on track. If you've ever found yourself puzzled by the "a git directory is found locally" issue while trying to add a Git submodule, you're not alone. I find one of the most common issues I run into is when I add a Git submodule and get back a response of the "a git directory is found locally" issue. I use Git Submodules in my blog ( ) to separately version control my content and public assets from my blog architecture.
#Git submodule add example free
Not interested in the Understanding the issue? Feel free to skip to the solution.

Step 4: Remove the relevant directory from.

