A
A
Alexander2021-07-12 20:11:39
git
Alexander, 2021-07-12 20:11:39

How to access submodule repositories?

After development, the project was transferred to the production server.
A project with two submodules - one from a public repository, the other from a private one.

Submodules will not be updated even from the public repository:

> git submodule update
Cloning into 'local/components/xxx'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of '[email protected]:Author/repo' into submodule path 'local/components/xxx' failed

What the hell is Permission denied if the repository is public?

The second problem is the use of the Deploy key - it is made for both the main repository and one of the submodules, but if I specified an alias for the main repository when cloning, then how to specify an alias with a deploy key for the submodule? How to change the submodule settings so that it now takes data not from github.com, but from github.com-my-repo?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-07-12
Madzhugin @Suntechnic

Part of the answer is this:
Create separate ssh keys for each repository and add them as deployment keys.
Create a .ssh/config file like this:

Host github.com-repo-1
        Hostname github.com
        IdentityFile=/home/bitrix/.ssh/id_rsa-repo-1
Host github.com-repo-2
        Hostname github.com
        IdentityFile=/home/bitrix/.ssh/id_rsa-repo-2
Host github.com-repo-3
        Hostname github.com
        IdentityFile=/home/bitrix/.ssh/id_rsa-repo-3

Next, we clone the repository using the deployment key:
git clone [email protected]:Author/repo.git .
Next, we change the local access URL to the submodule reps:
git config submodule.local/sources.url [email protected]:Author/repo2.git

and then we do:
git submodule init
 git submodule update

However, why Permission is denied for a public repository, and why does it need a deployment key and what to do if the public turnip is not mine, I still do not understand :(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question