Cloning Submodule Fails from Mirror

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible


Cloning a repository from a mirror that contains submodules results in one of the following errors:
Commandgit clone --recurse-submodules <Mirror URL>/git/Repository.git





This can happen when users who clone from the mirror don't have access to the upstream primary server.
When creating a Submodule, Git creates a .gitmodules file. By default, the configuration uses the upstream/primary server URL.

Example of default .gitmodules file with fully qualified URL:

user@host:~/bitDC-Repos/superproject$ cat .gitmodules 
[submodule "mod1"]
path = mod1
url = https://user@bitbucket-dc/scm/git/mod1.git
[submodule "mod2"]
path = mod2
url = https://user@bitbucket-dc/scm/git/mod2.git

If the user cloning from the mirror has no access to the upstream primary server, the above URLs can not be used.


Change Submodule URL from fully qualified URL/absolute to a relative path.

In order for this to work correctly for both HTTPS and SSH you need to meet the following criteria :

  1. All Repositories involved (SuperProject/Parent Repo and Submodule Repos) need to be on the server you are cloning from. This is true whether it is from a mirror or the upstream primary server.
  2. If cloning via SSH, you need to add SSH keys to all repositories involved.

You don't need to clone the submodules locally as separate repositories.
Once all the repositories are on the server (Upstream and Mirror) and the correct access has been provided,  you can
Change URLs to Relative Paths


The following command: git clone --recurse-submodules <Mirror URL>/git/Repository.git will now work.

For more information in regards to Git Submodules please refer to:

Last modified on Mar 23, 2022

Was this helpful?

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