在 GitHub 上使用别人的 repo 作为 Git 子模块 [英] Using someone else's repo as a Git Submodule on GitHub

查看:53
本文介绍了在 GitHub 上使用别人的 repo 作为 Git 子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以将其他人的存储库(或存储库的分支)用作您自己的 Git 存储库中的子模块.github 本身的文档要么丢失,要么我没有使用正确的术语来查找它.如果这不是将公共存储库作为共享库包含在 git 项目中的首选方式,我们将不胜感激作为替代最佳实践的建议.

I am trying to find out if it is possible to use someone else's repository (or branch of a repository) as a Submodule in your own Git repository. Documentation on github itself is either missing, or I'm not using the right terminology to look for it. If this isn't the preferred way to go about including a public repository as a shared library within ones git project, suggestions as an alternative best practice would be appreciated.

推荐答案

是的,您可以将任何存储库添加为项目中的子模块.就这样做:

Yes, you can add any repository as a submodule in your project. Just do:

git submodule add git://github.com/whomsoever/whatever.git

... 在存储库的顶层.这确实是使用 git 使用您自己的现有有用存储库的最简单方法.有关子模块的更多信息,您可以查看:

... in the top level of your repository. This is indeed the easiest way with git to use some existing useful repository within your own. For more information on submodules, you could look at:

  • Pro Git's section on submodules
  • The quite readable bit in the git manual
  • The section on submodules in the git community book

更新: 正如 jfountain 在下面指出的那样,如果您想在一个子目录路径(或与默认名称不同的名称),您可以将其作为该命令的附加参数提供,例如:

Update: as jfountain points out below, if you want to add the submodule at a subdirectory path (or with a name different from the default) you can supply that as an additional parameter to that command, e.g.:

git submodule add git://github.com/whomsoever/whatever.git foo/bar

这篇关于在 GitHub 上使用别人的 repo 作为 Git 子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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