git init 和 git clone 命令
git clone 将现有存储库的克隆或者副本创建到新目录中。
它是最常用的命令,它允许用户获取现有中央存储库的开发副本。
git clone 在本地机器的 team-project 文件夹中初始化一个新的存储库,并用中央存储库的内容填充它。
接下来,我们可以 cd 进入项目,开始修改文件、与其他存储库交互以及提交快照。
git init 和 git clone 命令通常相互混淆。
git clone 命令依赖于 git init 并创建一个已经存在的存储库的副本。
克隆包含子模块的存储库的步骤
按照接下来的 3 个步骤来解决问题:
克隆项目
首先,你应该 git clone 项目:
git clone <remote-repo-url>
初始化子模块
第二步是像这样设置子模块:
git submodule init
更新子模块
最后一步是更新子模块:
git submodule update
或者我们可以通过执行以下操作来缩短整个过程:
git submodule update --init
如果不初始化,子模块文件夹将保持为空。
但是我们可以使用有关 Git 版本的其他方法。
使用 Git 1.6.5 或者更高版本,我们可以执行一行:
git clone --recursive URL git://github.com/foo/example.git cd example
在 2.13 及更高版本中,我们可以使用 --recurse-submodules 而不是 --recursive
git clone --recurse-submodules -j8 git://github.com/foo/example.git cd example
-j8 是 2.8 版中提供的可选性能优化。
它最多可并行获取 8 个子模块。
从版本 1.9 到 2.12,使用以下内容:
git clone --recursive -j8 git://github.com/foo/example.git cd example
对于 1.6.5 及更高版本,我们可以调用:
如何克隆包括 Git 子模块
git clone --recursive git://github.com/foo/example.git cd example
对于克隆的存储库或者旧版本,请执行:
git clone git://github.com/foo/example.git cd example git submodule update --init --recursive
在克隆父git仓库的过程中子模块文件夹为空时可能会出现问题。
在本教程中,我们将展示几种克隆存储库的方法,以解决问题。
日期:2020-06-02 22:16:37 来源:oir作者:oir