Correct way to update git superproject

1.1k Views Asked by At

Scenario: We have recently started using a superproject in our team but seem to keep ending up having different versions of our superproject. We are all working on 1 branch of the project (but superproject has 3 remote branches). The issue seems to be that some files which have been deleted in the remote branch do not get removed when some of us do a:

git submodule foreach 'git checkout <branch_name> && git pull -r'

Even though a git status on any repo shows that our local branch is up to date with the remote branch. Sometimes, when an entire repo is deleted we also run across the problem of having different contents of the entire superproject.

What is the correct way (our team has about 3-4 different ways of doing this for some reason) of updating our superproject with what is on the remote branch that would allow us to have the same workspace when repos/directories inside repos are removed.

1

There are 1 best solutions below

0
On

Normally, a simple way to update submodules would be:

That is:

git submodule update --remote --recursive

That should be enough to update all submodules, synchronizing their working tree (unless those files were being modified)