exic
exic

Reputation: 2678

How to "git clone" including submodules which are not reachable from client host?

I want to clone a repository including its submodules.

I've learned about the --recursive option at this question, but this solution requires the submodule repositories to be accessible from the cloning host.

Is there some switch to clone the submodules directly from the accessible host?

There is a https proxy through which I can theoretically reach the submodules repos, but the cloning host doesn't have the needed certificates installed. So finding a way to install a certain https certificate in user space might be a solution as well.

Upvotes: 2

Views: 1123

Answers (1)

djpohly
djpohly

Reputation: 751

If the remote server (host1 in your comment) would have to execute a clone or fetch on your behalf, then no, you can't do this.

However, since the submodules are themselves repositories, you could use them directly if they are cloned on host1. After you clone the main repository, edit the .gitmodules file and change the Github URLs to the corresponding subdirectories of host1:mainrepo:

[submodule "submod1"]
        path = extern/sub1
        url = git://github.com/user/myproject

changes to

[submodule "submod1"]
        path = extern/sub1
        url = host1:git/mainproject/extern/sub1

You can then use the git submodules commands to work with them.

(You'll have to be careful though: don't commit your changes to .gitmodules or push commits into the submodules on host1 unless you really mean to!)


For your alternative question, check out the Git config settings http.proxy and http.sslCert. You should be able to provide a certificate file directly using the latter, without having to "install" it in the system CA path.

Upvotes: 2

Related Questions