我的问题和下面的类似:How do I update a GitHub forked repository?,但它有点复杂,因为我的上游是一个非常大的项目,有很多子模块。
git remote -v
navi_dev ssh://gitolite@hi0vm066.de.bosch.com/navi_development (fetch)
navi_dev ssh://gitolite@hi0vm066.de.bosch.com/navi_development (push)
origin cmg1szh@szhgit01.apac.bosch.com:navi_int_internal.git (fetch)
origin cmg1szh@szhgit01.apac.bosch.com:navi_int_internal.git (push)nave_dev是我想要获取的上游根目录,而origin是我的本地分支。
但在这个项目中,有很多子模块:例如:
[submodule "ai_osal_common"]
path = ai_osal_common
url = gitolite:ai_osal_common
[submodule "ai_osal_darwin"]
path = ai_osal_darwin
url = gitolite:ai_osal_darwin
...我的问题是,我还想将这些子模块分支到我的本地代码库中。子模块可以被更新,根上游也可以被更新,(根上游可以更新其子模块散列)。如何将root上游及其子模块同步到我的本地存储库?
发布于 2018-01-05 18:58:53
只需按照您提供的链接在每个子模块中执行相同的操作,但这将导致每个子模块将拥有来自其各自主分支的最新版本,而这可能是不正确的。
因此,我的建议如下:
# Fetch all the branches of navi_dev remote into remote-tracking branches:
git fetch navi_dev --recurse-submodules
# Make sure that you're on your master branch:
git checkout master --recurse-submodules
# Rewrite your master branch so that any commits of yours that
# aren't already in navi_dev/master are replayed on top of that
# other branch:
git rebase navi_dev/master如果您自己在任何子模块中进行了任何更改,则还必须在其原始远程主分支的基础上对其进行重新设置。
https://stackoverflow.com/questions/47917566
复制相似问题