如何配置父repo从子模块的头部更新?

时间:2017-03-16 20:06:44

标签: git git-submodules

我有一个父repo A和子模块repo B,它在master上的最新提交时检出。我已经在回购A中运行了git submodule update --init --recursive,所以我的子模块已经在其中。我知道我可以在该命令上抛出一个--remote标志,以便从最新的提交中更新它,但我能够弄清楚的是如何更改子模块提交#,这样每当有人else运行git submodule update --init --recursive,它也将从子模块中的最新提交更新。有任何想法吗?谢谢。

2 个答案:

答案 0 :(得分:0)

  

git submodule update --init --recursive,它也将从子模块中的最新提交更新。

不,该命令仅检出子模块 gitlink special entry in the parent repo)。

您需要添加--remote以强制分支更新(子模块内的git pull)
但请记住,如果在submodule.<path>.<branch>中找不到.gitmodules,则会更新任何子模块,默认为其上游主分支。
请参阅“Git: track branch in submodule but commit in other submodule (possibly nested)”。

答案 1 :(得分:0)

解决方案:

1)cd进入子模块 2)因为最后一个子模块更新让我进行了最新的提交,我只是查看了最新的提交(git checkout [commit_hash]) 3)cd出去并回到父回购 4)git add submodule - &gt;提交 - &gt;推