1

My question is similar with the following: How do I update a GitHub forked repository? 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.

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?

Rajeev Desai
  • 144
  • 2
  • 12
Richardicy
  • 103
  • 1
  • 1
  • 4

1 Answers1

2

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.

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.

Jan Lovstrand
  • 228
  • 2
  • 9