2

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.

Community
  • 1
  • 1
exic
  • 2,220
  • 1
  • 22
  • 29
  • is the main repo a bare repository? – CharlesB Sep 11 '12 at 16:23
  • In this case, no. It is clone of a bare repository. client:mainrepo is a clone of host1:mainrepo and host1:mainrepo is a clone of server:mainrepo which itself is a bare repo. mainrepo:submodules are github.com repositories. – exic Sep 11 '12 at 17:07
  • I don't think it is possible due to security reasons. – kan Sep 11 '12 at 18:28

1 Answers1

2

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.

djpohly
  • 711
  • 5
  • 8
  • Usually server's repo is bare, so it doesn't have submodule's stuff except its url. So, I think it is impossible. – kan Sep 11 '12 at 19:56
  • Usually, yes; however, the OP indicated in the comments on the question that the repository being cloned from is not bare. – djpohly Sep 11 '12 at 20:02
  • Since there seems to be no other option than changing the url, I'm using this for now: `origin=$(git config --get remote.origin.url); for submodule in $(git submodule status | awk '{print $NF}'); do git clone $origin/$submodule $submodule; done; unset origin`. https however appears to be no option as libcurl-gnutls.so.4 is missing on the client host. – exic Sep 12 '12 at 11:38