运行有什么区别
git submodule update --remote
对比
cd <submodule directoy>
git pull
假设子模块之前设置为跟踪某个分支:
git submodule add -b master [URL to Git repo]
最佳答案
区别在于:
git pull 只会更新您的子模块分支,但它可以是您可以在该子模块仓库中 checkout 的任何分支。git submodule update --remote 只会更新在 .gitmodule 中注册的分支,默认情况下,你最终会得到一个分离的 HEAD,除非 --rebase 或 --merge 被指定或关键字 submodule.$name.update 被设置为 rebase, merge 或 none。在这两种情况下,您仍然需要返回父仓库,添加并提交新的子模块 SHA1 引用。
这是因为在这两种情况下,子模块的 SHA1 都发生了变化,这意味着 gitlink (父存储库的 special entry in the index,以子模块的根文件夹命名)必须添加并提交。
A git submodule update --init --remote就像:
git submodule init : 初始化( check out )索引中记录的子模块git submodule update --remote : 在子模块初始化( checkout )后,从已注册的分支(默认情况下为 master) pull 。关于git submodule update --remote vs git pull,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19619747/