[英]GitHub: How to fork a public repository as a subdirectory in a private repository?
My project is currently hosted in a private repository.我的项目目前托管在私有存储库中。 I'm looking to introduce a dependency to a third party library hosted in a public repository on GitHub. How can I fork the library so that it becomes a subdirectory in my project, but I can still sync from the trunk branch of that library?
我正在寻找对 GitHub 上公共存储库中托管的第三方库的依赖项。我如何分叉该库,使其成为我项目中的子目录,但我仍然可以从该库的主干分支同步?
This is called submodule and is described in details at http://git-scm.com/book/en/Git-Tools-Submodules这称为子模块,在http://git-scm.com/book/en/Git-Tools-Submodules中有详细描述
This sequence would get you set up:这个顺序会让你设置:
cd <my-project-dir>
git submodule add <github repository> <my-third-party-dir> # -b <branch> optionally
git submodule init
git submodule update
At this point you've got my-third-party-dir populated with a particular commit (a detached head).此时,您的my-third-party-dir已经填充了一个特定的提交(一个分离的头部)。 Your project will have two changes.
您的项目将有两个更改。
git add .gitmodules <my-third-party-dir>
git commit -m 'Added <repository> as a submodule'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.