当前位置:   article > 正文

git仓库子模块下载失败怎么办_git hub 子仓库没有下载

git hub 子仓库没有下载

如何在clone和pull时带上子模块

对于有子模块的部分clone和pull时应该加上 --recurse,

按照手册Git - git-clone Documentation (git-scm.com),应该使用 --recurse-submodules

而实测--recurse也是可以的

比如obs项目:

git clone --recursive https://github.com/obsproject/obs-studio.git

子模块的定义在哪里 

obs项目目录下有一个.gitmodules文件描述了相关子模块

  1. [submodule "plugins/win-dshow/libdshowcapture"]
  2. path = plugins/win-dshow/libdshowcapture
  3. url = https://github.com/obsproject/libdshowcapture.git
  4. [submodule "plugins/mac-syphon/syphon-framework"]
  5. path = plugins/mac-syphon/syphon-framework
  6. url = https://github.com/palana/Syphon-Framework.git
  7. [submodule "plugins/enc-amf"]
  8. path = plugins/enc-amf
  9. url = https://github.com/obsproject/obs-amd-encoder.git
  10. [submodule "plugins/obs-browser"]
  11. path = plugins/obs-browser
  12. url = https://github.com/obsproject/obs-browser.git
  13. [submodule "plugins/obs-vst"]
  14. path = plugins/obs-vst
  15. url = https://github.com/obsproject/obs-vst.git
  16. [submodule "plugins/obs-outputs/ftl-sdk"]
  17. path = plugins/obs-outputs/ftl-sdk
  18. url = https://github.com/Mixer/ftl-sdk.git

如果clone时忘了下子模块怎么办

执行

git.exe submodule update --init

或者在Tortoise Git右键菜单->Git Sync中选择Submodule Update

如果clone子模块失败时怎么办

执行下上节的update,直到没有出错信息,此时可以用以下指令查到各子模块的状态

git.exe submodule status

C:\GitHub\obs-studio>git.exe submodule status
 9a08b071dfefc6cfb7e974a8b29898a79d668ca0 plugins/enc-amf (2.6.0-13-g9a08b07)
 01b144811f6f7080b70b2d7cc729da071f86f9d7 plugins/mac-syphon/syphon-framework (heads/master)
 dd3d7eb2ad99c1aebe7c3c6a37f411c080c7fcdf plugins/obs-browser (2.16.3-21-gdd3d7eb)
 d0c8469f66806b5ea738d607f7d2b000af8b1129 plugins/obs-outputs/ftl-sdk (v0.9.14-8-gd0c8469)
 6ebb4f5e8e42ab5cc011bedf937a2127d1816bee plugins/obs-vst (heads/master)
 5ac25cba2e90e617293c373bcc3ce59e46197bef plugins/win-dshow/libdshowcapture (heads/master) 

不过此时目录下还是空空如也,细节可以参考下节

如果update完以后目录下还空空如也怎么办

 具体原因并不清楚,但是状态是子模块的文件都被删除了

C:\GitHub\obs-studio>git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
        modified:   plugins/mac-syphon/syphon-framework (modified content)
        modified:   plugins/obs-outputs/ftl-sdk (modified content)

no changes added to commit (use "git add" and/or "git commit -a")

 这个时候只要跑到子目录去revert掉相关子模块的修改即可,

注意:在项目根目录直接revert是无效的,需要到子目中revert才开;在子模块目录上右击选择Tortoise Git右键菜单->revert

至于子模块的位置,可以根据git status的结果来查看;也可以根据本文中“子模块的定义在哪里”章节的内容查看

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号