Cloning Submodule Fails from Mirror

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server と Data Center のみ - この記事は、サーバーおよびデータセンター プラットフォームのアトラシアン製品にのみ適用されます。

問題

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

fatal: clone of '<Upstream URL for Submodule>' into submodule path '<.../Repository/submodule>' failed
Failed to clone '<submodule name>'. Retry scheduled
Cloning into '<LocalPath.../Repository/submodule>'...
fatal: unable to access '<Upstream URL>': Could not resolve host: <HOST-NAME>
fatal: clone of '<Upstream URL for Submodule>' into submodule path '<.../Repository/submodule>' failed
Failed to clone '<submoodule name>' a second time, aborting

または

Submodule '<submodule name>' (<Upstream URL for Submodule>) registered for path '<submodule name>'
Cloning into ''<LocalPath.../Repository/submodule>'...
fatal: early EOF
fatal: The remote end hung up unexpectedly
fatal: index-pack failed
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: clone of '<Upstream URL for Submodule>' into submodule path '<LocalPath.../Repository/submodule>' failed
Failed to clone '<submodule name>'. Retry scheduled 
...


原因

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

Example of default .gitsubmodules file with full 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 URL's 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 you are cloning from. This is true weather its 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

[submodule "mod1"]
path = mod1
url = ../mod1.git
[submodule "mod2"]
path = mod2
url = ../mod2.git 


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 2, 2018

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.