git子模块不能持续更新

时间:2016-05-30 14:28:08

标签: git

我的工作场所最近转而使用git以及设置组件的功能,这些组件作为子模块在项目之间共享,这导致了试图弄清楚如何使用它们的人们的普遍沮丧。

在阅读了一些互联网建议后,我按如下方式拉出项目和子模块:

git pull --recurse-submodules
git submodule update --recursive --remote --init --merge

但是,有时检查子模块的状态会给我一些:

> git status
On branch feature
Your branch is behind 'origin/feature' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working directory clean

如果我这样做就解决了

git submodule foreach git pull

我不知所措。你能告诉我我做错了吗?

谢谢!

2 个答案:

答案 0 :(得分:2)

来自OP的评论:

  

我的印象是git submodule update会拉动   最新的子模块,它显然不是

确实没有。它的作用在例如here中解释:

  

<强>更新

     

通过克隆丢失的子模块并更新工作树来更新已注册的子模块以匹配超级项目所期望的内容   子模块。

     

<强>合并

     

超级项目中记录的提交将合并到子模块中的当前分支。

Superproject将始终记录有关其每个子模块的特定提交。更新命令将使用该提交并将其检出 - 它实际上不会更新它以引用项目可能具有的任何新情况。

你本身没有做错任何事,这就是它的工作方式。如果要将录制的提交移动到最新的提交,则必须以其他方式执行此操作。在this other thread中更好地解释了这一点,但简而言之,执行--remote代替--merge看起来就像是你追求的事情。

答案 1 :(得分:-2)

git pull origin yourbranch --recursive
cd submodulebrach
git checkout submodulebrach
cd ..
git commit -m submodule
git push origin yourbranch 
相关问题