方法一
1 | git clone --recursive 项目地址 |
Cloning into 'testblog'...
remote: Enumerating objects: 295, done.
remote: Counting objects: 100% (295/295), done.
remote: Compressing objects: 100% (243/243), done.
remote: Total 295 (delta 38), reused 251 (delta 19) KiB/s
Receiving objects: 100% (295/295), 1.63 MiB | 29.00 KiB/s, done.
Resolving deltas: 100% (38/38), done.
Submodule 'themes/next' (https://github.com/bianxinxin/hexo-theme-next) registered for path 'themes/next'
Cloning into 'D:/Code/testblog/themes/next'...
remote: Counting objects: 12041, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 12041 (delta 0), reused 4 (delta 0), pack-reused 12034
Receiving objects: 100% (12041/12041), 12.99 MiB | 194.00 KiB/s, done.
Resolving deltas: 100% (6963/6963), done.
Submodule path 'themes/next': checked out '54d65412c9351cf2ff11e6b0cc1ee426a9529f97'
方法二
1 | git clone 仓库地址 克隆该项目 |
克隆下来后只会发现子模块并没有一起克隆下来,需要将子模块也克隆下来。
git submodule init 初始化你的本地配置文件
git submodule update 从那个项目拉取所有数据并检出你上层项目里所列的合适的提交
报错处理
如果如下错误:
1
2Please make sure you have the correct access rights
fatal: Could not read from remote repository.是因为没有子模块的操作权限导致的,添加权限。
- git submodule update 报如下错误:
1
2
3$ git submodule update --init
fatal: Needed a single revision
Unable to find current revision in submodule path ’xxx子模块库名xxx’
解决
1 | rm -rf xxx子模块库名xxx |