该git
文档并未完全阐明a git submodule update
和a 之间的区别是什么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.
--
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.
供参考,我使用的是git客户端版本2.11.0
update
基本上是git pull
在每个子模块中执行(没有分支除外,因为主仓库直接指定提交)。
棘手的是sync
。假设您使用子模块克隆了一个项目,然后上游项目将子模块之一更改为指向另一个URL。
子模块的本地副本仍将指向旧的URL,因为git 绝对不允许远程存储库强制更改本地配置。您需要运行git submodule sync
以将远程存储库的配置应用于本地子模块存储库。
还要注意,如果要更改子模块,即使上游从未更改过它们,您可能也希望 URL不匹配...但是对于这种情况,使用多个远程URL可能是一个更好的主意。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句