GitHub:如何将公共存储库作为私有存储库中的子目录进行分叉?

zer*_*lus 6 git github

我的项目目前托管在私有存储库中.我想在GitHub上的公共存储库中托管第三方库的依赖项.如何分叉库以使其成为我项目中的子目录,但我仍然可以从该库的trunk分支同步?

GoZ*_*ner 7

这个序列可以让你设置:

cd <my-project-dir>
git submodule add <github repository> <my-third-party-dir>   # -b <branch> optionally
git submodule init
git submodule update
Run Code Online (Sandbox Code Playgroud)

此时,您已经使用特定提交(一个分离的头)填充了我的第三方目录.您的项目将有两个更改.

git add .gitmodules <my-third-party-dir>
git commit -m 'Added <repository> as a submodule'
Run Code Online (Sandbox Code Playgroud)