git GitHub 包含来自另一个存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17775828/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:48:37  来源:igfitidea点击:

GitHub include from another repository

gitgithub

提问by ramaralo

I'm new to github.

我是 github 的新手。

I have a github repo on my machine. I want to include another repo (as a third party) into my repo. I believe I should make a fork first. But how do I include it on my local repo?

我的机器上有一个 github 仓库。我想将另一个 repo(作为第三方)包含在我的 repo 中。我相信我应该先做一个叉子。但是我如何将它包含在我的本地存储库中?

I've tried submodules but with no success...

我试过子模块但没有成功......

Thanks.

谢谢。

回答by VonC

git submoduleremains the recommended way: you can declare (git submodule add) a repo which doesn't belong to you, or a fork (which, by definition, belongs to you).

git submodule仍然是推荐的方式:您可以声明 ( git submodule add) 一个不属于您的 repo,或一个 fork(根据定义,属于您)。

Don't forget though, that:

但不要忘记,那:

  • you still need to git submodule update --initin order to see that submodule repo being displayed with its full content in your repo
  • add and commit the special entryrepresenting the root directory of that submodule in your main (parent) repo, and push that commit, in order to validate that declaration.
  • 你仍然需要git submodule update --init为了看到子模块 repo 在你的 repo 中显示它的全部内容
  • 在主(父)存储库中添加并提交代表该子模块根目录的特殊条目,然后推送该提交,以验证该声明。