简体   繁体   English

如何使用子模块更新GitHub分叉存储库

[英]How do I update a GitHub forked repository with submodule

My question is similar with the following: How do I update a GitHub forked repository? 我的问题与以下内容类似: 如何更新GitHub分叉存储库? But it's a bit complicated, because my upstream is a very large project which have a lot of sub modules. 但这有点复杂,因为我的上游是一个非常大的项目,其中包含许多子模块。

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 is the root upstream I want to get from, and origin is my local fork. nave_dev是我要从其获取的上游根目录,而origin是我的本地fork。

but in this project, there are lots of sub modules: such as: 但是在这个项目中,有很多子模块:

[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

...

My Question is, I also want to fork these submodules into my local repo. 我的问题是,我也想将这些子模块派生到本地存储库中。 The submodules could be updated, and the root upstream could also be updated, (root upstream may update its submodule hash). 可以更新子模块,还可以更新上游根目录(上游上游根目录可以更新其子模块哈希)。 How could I sync both the root upstream and its submodules into my local repo? 如何将根上游及其子模块同步到本地存储库中?

Just do the same thing in each submodule as the link you provided suggested, but that will lead to that each submodule will have the latest from their respective master branch, and that may not be correct. 只需按照您提供的链接在每个子模块中执行相同的操作,但这将导致每个子模块具有其各自的master分支中的最新消息,这可能是不正确的。

So my suggestion is the following: 所以我的建议如下:

# 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

If you have made any changes yourself in any submodule, you have to rebase them also on top of their original remote master branch. 如果您自己在任何子模块中进行了任何更改,则必须在其原始远程master分支之上重新设置它们的基础。

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

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