我有一个Xcode项目,它本身具有Git源代码控制。在一个名为Libraries的文件夹中,我克隆了另外八个来自GitHub的Git项目。它们位于我的Git仓库内,并且我已将所有这些库添加到我的git提交中。
是否有一种方法可以让git从它们的仓库下载它们的代码,而不是将所有这些git库的代码包含到我的仓库中呢?或者将其他git仓库包含到项目中是否正常?
当然可以按照以下步骤操作:
打开终端并执行以下命令
cd /path/to/your/main/repo
git submodule add git@github.com:someuser/somerepo.git somerepo
git commit -m "Added submodules"
现在,你不再需要复制这些文件,而是在你的项目中引用其他仓库:
编辑:
如果你想将子模块更新到最新的提交,可以执行以下操作:
cd somerepo
git pull # You can also checkout a branch / tag etc.
cd ..
git add somerepo
git commit -m "Telling the main repo to update the reference to the referenced repo"
git submodule add https://github.com/AlanQuatermain/AQGridView.git Libraries/AQGridView
而不是 git@github.com:...
? - dhrmgit pull
命令? - dhrmsomerepo
中的任何更改,但是你还需要告诉你的主要代码库更新引用。请参考我的更新帖子。顺便说一句:我发现子模块非常方便,因为你不必复制已经通过 git 可以访问的存储库中的代码。 - Besi