Ben*_*ber 34 git git-submodules
该git
文档不让它完全清楚的区别是什么之间git submodule update
和git submodule sync
为.我也没有在网上找到任何帮助.有人可以帮助我解决这里的不同之处吗?
update
Update the registered submodules to match what the superproject expects
by cloning missing submodules and updating the working tree of the
submodules. The "updating" can be done in several ways depending on
command line options and the value of submodule.<name>.update
configuration variable.
Run Code Online (Sandbox Code Playgroud)
-
sync
Synchronizes submodules' remote URL configuration setting to the value
specified in .gitmodules. It will only affect those submodules which
already have a URL entry in .git/config (that is the case when they are
initialized or freshly added). This is useful when submodule URLs
change upstream and you need to update your local repositories
accordingly.
Run Code Online (Sandbox Code Playgroud)
作为参考,我使用的是git客户端版本2.11.0
o11*_*11c 39
update
基本上是git pull
在每个子模块中进行(除了没有分支,因为主repo直接指定了一个提交).
棘手的是sync
.想象一下,您使用子模块克隆项目,然后上游项目会更改其中一个子模块以指向不同的URL.
您的子模块的本地副本仍将指向旧URL,因为git 从不允许远程存储库强制更改本地配置.您需要运行git submodule sync
以将远程repo的配置应用于本地子模块存储库.
另请注意,如果要对子模块进行更改,您可能希望 URL不匹配,即使上游从未更改过它们......但使用多个远程URL可能更适合这种情况.
lar*_*sks 24
git submodule update
更新子模块的内容.它在每个子模块中有效地运行"git fetch"和"git checkout".
git submodule sync
更新子模块的元数据以反映子模块URL中的更改.它将信息.git/config
与信息重新同步.gitmodules
.