Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download git submodules for tarball

Is it possible to download submodules for a repository with only the working directory?

If I download a tarball of a repository from GitHub, that is equivalent to a shallow clone without the .git folder, is it at all possible to "download" the submodules into the working directory?

I tried git init && git submodule update --init, but this neither initializes nor does it update the submodules. The .gitmodules file is in the current directory.

Update: Some more background on the question: We'd like to use tarballs for checking out repositories at Travis CI, but several people use git submodules. "Don't use Git submodules" would therefore not be a good answer, but the answer doesn't really have to be something maintainable either. I just want a folder that has the code checked out and with the submodules initialized, there's no need for anything that allows me to pull down more changes later.

like image 436
sarahhodne Avatar asked Jul 25 '13 02:07

sarahhodne


1 Answers

Combining a wget/tar approach, with a git init won't help you initialize submodules:

Everything is untracked after the git init.

You need to add and commit everything, before:

git submodule update --init --recursive --force

That git submodule command will then "work", but create only empty directories.
That is because the tar file didn't include the special entries (160000) created by a git submodule add.

You need to re-declare those submodules:

C:\prog\git\ReactiveCocoa-2.0-development>git submodule add --name xcconfigs https://github.com/jspahrsummers/xcconfigs.git external\xcconfigs
Cloning into 'external\xcconfigs'...
remote: Counting objects: 312, done.
remote: Compressing objects: 100% (229/229), done.
Receal 312 (delta 87), reused 306 (delta 82)
Receiving objects: 100% (312/312), 64.51 KiB | 0 bytes/s, done.
Resolving deltas: 100% (87/87), done.
like image 175
VonC Avatar answered Oct 05 '22 19:10

VonC