Resolve the "No URL found for submodule path" in Git

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Purpose

Provide steps to resolve submodule path errors in Git

Diagnosis

  • A user updates their .gitmodules file to point to a new path for their submodule in another repository.

  • The user then attempts to update the git submodules in the remote repository (either using GIT or in Bitbucket Cloud Pipelines) by using some variation of the following command:

    1 git submodule update --init --recursive
  • They are then met with the following error message - which points to the old path that was previously referenced in their .gitmodules file: fatal: No url found for submodule path 'x' in .gitmodules

Cause

The old submodule path remains cached (and must be removed) or a path does not exist (and must be created) before the submodules may be updated.

Solution

You will need to perform the following on your local repository:

  1. Check the currently configured git submodules by executing the following to verify the submodule path status:

    1 git submodule status

    If the old path is present:

    You will need to execute the following command to remove this from the cache:

    1 git rm --cached old/path

    If no path is present:

    Create the mapping reference by entering the following into your .gitmodules file in the root of your repository:

    [submodule "path_to_submodule"] path = path_to_submodule url = git://url-of-source/

    path_to_submodule: is the actual path within your repository (relative to the root) where the submodule will be used.

    url-of-source: is the URL of the original repository that contains the submodule's files.

  2. After completing the steps, check the path configuration before updating the submodules:

    1 git submodule status
  3. Once complete, execute the same command as prior - you should no longer see the error message:

    1 git submodule update --init --recursive
  4. You will need to commit the changes and push them to your remote repository to resolve the issue now that the .gitmodules file has been updated with the new path, the old path has been removed from the cache, and the config has been updated.

If you are still encountering issues after following the steps contained within this knowledge article, please feel free to raise a support ticket or raise a community support ticket for further assistance. 

Updated on April 16, 2025

Still need help?

The Atlassian Community is here for you.