git submodule update --remote vs git pull

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19619747/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:12:27  来源:igfitidea点击:

git submodule update --remote vs git pull

gitgit-submodules

提问by user2924714

What is the difference between running

跑步有什么区别

git submodule update --remote

vs

对比

cd <submodule directoy>
git pull

Assuming that the submodule was previously set to track some branch:

假设子模块之前设置为跟踪某个分支:

git submodule add -b master [URL to Git repo]

回答by VonC

The difference is:

区别在于:

  • git pullwill only update your submodule branch, but it can be any branch that you could have checked out yourself in that submodule repo.
  • git submodule update --remotewill only update the branch registered in the .gitmodule, and by default, you will end up with a detached HEAD, unless --rebaseor --mergeis specified or the key submodule.$name.updateis set to rebase, mergeor none.
  • git pull只会更新您的子模块分支,但它可以是您可以在该子模块存储库中自己检出的任何分支。
  • git submodule update --remote只会更新注册分公司.gitmodule,并在默认情况下,你将最终获得一个分离的头,除非--rebase--merge指定或键submodule.$name.update设置为rebasemergenone

In both cases, you still have to go back to the parent repo, add and commit the new submodule SHA1 reference.
That is because in both instances, the SHA1 of the submodule changes, which means the gitlink(special entry in the indexof the parent repo, named after to root folder of the submodule) must be added and committed.

在这两种情况下,您仍然必须返回父存储库,添加并提交新的子模块 SHA1 引用。
这是因为在这两种情况下,子模块的 SHA1 都发生了变化,这意味着必须添加和提交gitlink(父存储库索引中的特殊条目,以子模块的根文件夹命名)。