赞
踩
对于有子模块的部分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文件描述了相关子模块
- [submodule "plugins/win-dshow/libdshowcapture"]
- path = plugins/win-dshow/libdshowcapture
- url = https://github.com/obsproject/libdshowcapture.git
- [submodule "plugins/mac-syphon/syphon-framework"]
- path = plugins/mac-syphon/syphon-framework
- url = https://github.com/palana/Syphon-Framework.git
- [submodule "plugins/enc-amf"]
- path = plugins/enc-amf
- url = https://github.com/obsproject/obs-amd-encoder.git
- [submodule "plugins/obs-browser"]
- path = plugins/obs-browser
- url = https://github.com/obsproject/obs-browser.git
- [submodule "plugins/obs-vst"]
- path = plugins/obs-vst
- url = https://github.com/obsproject/obs-vst.git
- [submodule "plugins/obs-outputs/ftl-sdk"]
- path = plugins/obs-outputs/ftl-sdk
- url = https://github.com/Mixer/ftl-sdk.git
执行
git.exe submodule update --init
或者在Tortoise Git右键菜单->Git Sync中选择Submodule Update
执行下上节的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)
不过此时目录下还是空空如也,细节可以参考下节
具体原因并不清楚,但是状态是子模块的文件都被删除了
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的结果来查看;也可以根据本文中“子模块的定义在哪里”章节的内容查看
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。