2

In my project, im using a third party library. I had git cloned this lib in my project, and then had done git submodule init and git submodule update in the lib folder. I pushed my main project to github, but the contents of this third party lib were not sent and the lib folder appears like a green folder in my github project repo.

If i clone my main project on another machine, i dont have the contents of the lib there.So, should i git clone the lib again on the machine and run the init and update commands again or is there any way to push the contents of the 3rd party lib to my github repo ?

Thank You

Kris
  • 1,403
  • 3
  • 17
  • 26

3 Answers3

5

Note that since April, 30th 2013, when you view a repository with a submodule on github.com, you get useful links and information for the submodule:

submodule

You now can see what exact reference a submodule points to.

The Repository Contents API will reflect that SHA1.

curl https://api.github.com/repos/jquery/jquery/contents/test/qunit

{
  "name": "qunit",
  "path": "test/qunit",
  "type": "submodule",
  "submodule_git_url": "git://github.com/jquery/qunit.git",
  "sha": "6ca3721222109997540bd6d9ccd396902e0ad2f9",
  "size": 0,
  "url": "https://api.github.com/repos/jquery/jquery/contents/test/qunit?ref=master",
  "git_url": "https://api.github.com/repos/jquery/qunit/git/trees/6ca3721222109997540bd6d9ccd396902e0ad2f9",
  "html_url": "https://github.com/jquery/qunit/tree/6ca3721222109997540bd6d9ccd396902e0ad2f9",
  "_links": {
    "self": "https://api.github.com/repos/jquery/jquery/contents/test/qunit?ref=master",
    "git": "https://api.github.com/repos/jquery/qunit/git/trees/6ca3721222109997540bd6d9ccd396902e0ad2f9",
    "html": "https://github.com/jquery/qunit/tree/6ca3721222109997540bd6d9ccd396902e0ad2f9"
  }
}
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Yes, the submodule is essentially a git repository of its own. The parent git project simply references a particular commit. Refer to the help for git submodule for the details as to how to maintain them. Yes, you do need to init and update the repository for each submodule, however, you will find that there are commands (in the help) that do a lot of that for you.

Arafangion
  • 11,517
  • 1
  • 40
  • 72
1

I had the same problem: I wanted to try some code from a project repo hosted on github, and so I cloned it. None of the build commands worked until my coworker told me about the magic incantation:

git submodule update --init

which cloned the submodules referenced in the repo properly. None of this was clear to me either, from "git submodule help" or "man git-submodule".

Good luck!

wangd
  • 21
  • 2