2017-03-16 57 views
1

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

回答

0

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

否,该命令仅检查出在被记录gitlinkspecial entry in the parent repo)子模块。

你需要(内拉的git子模块日)添加--remote迫使分支更新
但是要记住,任何子模块将被更新,如果没有​​在.gitmodules发现拖欠其上游主分支。
请参阅“Git: track branch in submodule but commit in other submodule (possibly nested)”。

0

解决方式:

1)CD插入子模块 2)自上次更新子模块有我的一个承诺,这不是最新的,我刚刚签出最新的提交(git checkout [commit_hash]) 3)CD在那里,回到父回购 4)git add submodule - > commit - > push

+0

你不需要:如果你的子模块设置为跟踪一个分支(就是说如果它有一个' submodule。''.gitmodules')'--remote'就足够了。 – VonC