github回购中的Git子模块 [英] Git submodules in github repo

查看:129
本文介绍了github回购中的Git子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,即时通讯使用第三方库。我把git克隆到了我的项目中,然后在lib中完成了 git submodule init git submodule update 夹。我把我的主项目推到了github上,但是这个第三方lib的内容没有被发送,lib文件夹在我的github项目库中显示为绿色文件夹。



如果我克隆我的主要项目在另一台机器上,我没有在那里的lib的内容。所以,我应该克隆在机器上的库再次运行的init和更新命令或有任何方法来推动的内容第三方库到我的github回购?



谢谢

解决方案

请注意,自2013年4月30日起,当您在github.com上查看包含子模块的存储库时,您将获得子模块的有用链接和信息:



您现在可以看到子模块指向的确切引用。



Repository内容API 将反映这个t 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
}
}


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

解决方案

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:

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"
  }
}

这篇关于github回购中的Git子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆