27

I have a GitHub repository and use another project as a submodule. This submodule is also in .gitmodules, the code below:

[submodule "inc/tha"]
    path = inc/tha
    url = git://github.com/zamoose/themehookalliance.git

See also in view on GitHub.

submodule in repo

How is it possible to download my GitHub repository, including the submodule files?

bueltge
  • 2,294
  • 1
  • 29
  • 40

1 Answers1

14

This (include the submodule with a GitHub zip or tarball download: the Nodeload service) isn't currently supported, as mentioned in this thread.

This script revision would make the zip itself from a GitHub repo, including submodules, through multiple calls to https://nodeload.github.com/user/repo/zipball/branch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 6
    Thanks for the answer; pity, that github has no solution. – bueltge Oct 18 '12 at 09:43
  • @bueltge true, but at least the `sublime_package_control` project offers you a way to get *everything* for a given repo. – VonC Oct 18 '12 at 09:44
  • 1
    Yes, I have read them, but is pythen and is not my current language, maybe later and current only on the wishlist. – bueltge Oct 18 '12 at 09:45
  • @bueltge I understand, but the idea is there: parsing the `.gitmodules` file and calling https://nodeload.github.com/user/repo/zipball/branch for each modules declared there. That could be adapted in any script language. – VonC Oct 18 '12 at 10:16
  • This is a fine idea. I will see forward for this solution to include this. Maybe the project have a documentation in different language or a template in python for easy to use. – bueltge Oct 18 '12 at 11:45
  • This answer is correct and all, but I'd like to get an explanation on how to actually implement this solution? Do I have to run this python script locally or is there something that can be done with the github repo? – birgersp Jan 20 '17 at 08:00
  • 1
    @Birger It is meant to be run locally, in order to complete the zip of the main repo. – VonC Jan 20 '17 at 08:09
  • From what I have observed, real submodule-uninitialized Git repos have a file at the path that should be the submodule directory, with the submodule's SHA in the file. Therefore `git submodule update --init --recursive` is not necessarily the latest commit in the branch. However this information is not included in the GitHub zipball download – SOFe Jan 30 '17 at 13:47
  • After additional research, this seems to be only possible with an additional call to the GitHub Contents API, which the `"sha"` returns the submodule commit. See also https://developer.github.com/v3/repos/contents/#response-if-content-is-a-submodule – SOFe Jan 30 '17 at 13:55
  • @PEMapModder "real submodule-uninitialized Git repos have a file at the path that should be the submodule directory, with the submodule's SHA in the file": correct. The gitlink (http://stackoverflow.com/a/16581096/6309, http://stackoverflow.com/a/19354410/6309) is not, I suspect, present in the archive though. Meaning you cannot know the exact SHA1 unless you are using the GitHub Content API you mention. – VonC Jan 30 '17 at 13:58
  • For others' reference: I used [this method](https://github.com/poggit/poggit/blob/cf1aef414deaa922f8faf56bb1c9ed5fd8d7e931/src/poggit/builder/RepoZipball.php) to imitate a virtual filesystem with recursive cloning. – SOFe Jan 31 '17 at 06:36