简体   繁体   English

git pull之后,执行“ git submoudle update”是否会更新子模块?

[英]Does doing 'git submoudle update' update the submodule after git pull?

I am newbie to git submodule and I am really confused by the documentation available regarding git submodules. 我是git子模块的新手,而关于git子模块的可用文档确实让我感到困惑。 My question is pretty straight forward 我的问题很简单

I have been away for 2 months and I want to update my local repo code. 我已经离开了两个月,我想更新我的本地仓库代码。 My repo which has submodules in it. 我的仓库中有子模块。 I do 我做
git pull origin master (It updates the code in my local repo.) git pull origin master (它会更新本地存储库中的代码。)
Now I want to update the submodules 现在我要更新子模块

So for that, is doing 所以为此

git submodule update enough? git子模块更新足够了吗?

I also see the command 我也看到了命令

git submodule foreach git pull origin master git子模块foreach git pull origin master
in the text of updating the submodules. 在更新子模块的文本中。

This command, in my opinion, is doing git pull for each submodule. 我认为该命令正在为每个子模块执行git pull。 But in my repo, every submodule is in detached head state. 但是在我的仓库中,每个子模块都处于分离头状态。 When I go in their subdirectory and do git branch, it says (no branch) which I think means that it is in detach head state. 当我进入他们的子目录并执行git分支时,它说(无分支) ,我认为这意味着它处于分离头状态。 So if it is not in any branch, then where with pulled code be placed. 因此,如果它不在任何分支中,则将放置拉出代码的位置。

So what is the right way for me to ensure that my repo is in update state. 那么,确保我的存储库处于更新状态的正确方法是什么?

The command git submodule update is enough to get all registered submodules. git submodule update命令足以获取所有已注册的子模块。 If you want to update submodules of submodules then you'd need git submodule update --recursive . 如果您想更新子模块的子模块,然后你需要git submodule update --recursive

Note that submodules are usually checked out to a specific commit and thus having two months pass between updates won't change the commit associated with the submodule. 请注意,子模块通常检出到特定提交,因此两次更新之间相隔两个月不会改变与子模块关联的提交。 However, if you did your submodule configuration to use branches, then if those branches have in fact evolved in two months, then you will get the changes. 但是,如果您对子模块进行了配置以使用分支,那么,如果这些分支实际上已经在两个月内发展了,那么您将获得更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM