Fix error "fatal: No url found for submodule path in .gitmodules"

Still need help?

The Atlassian Community is here for you.

Ask the community

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

   

Purpose

The purpose of this KB article is to provide context as to why this issue may occur and how to address this.

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:

    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

Procedure

Essentially, the root cause of the issue is that either the old submodule path remains cached (and must be be removed) or a path does not exist (and must be created) before the submodules may be updated.

To check this, 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:


    git submodule status


    If the old path is present:
    You will need to execute the following command to remove this from the cache:


    git rm --cached old/path

    If no path is present:
    To create the mapping reference, enter 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. Once the above has been actioned, double-check the path configuration before updating the submodules:

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


    git submodule update --init --recursive



  4. Now that the .gitmodules file has been updated with the new path/old path has been removed from cache/updated in the config - you will need to commit the changes and push them to your remote repository to resolve the issue.


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. 

DescriptionBitbucket Cloud - Fix Error "fatal: No url found for submodule path in .gitmodules"
ProductBitbucket Cloud
Last modified on Jan 26, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.