Search code examples
gitgit-submodules

git submodule update upstream


I have a super project with a submodule in it (Overleaf project). I have made changes to the submodule but they are not showing up in the super project. I want to update the superproject to reflect the latest commits to the submodule. My understanding is that git submodule update acts on the submodule to fetch the latest commits from the super project but how do I do the reverse?

When in the superproject I run git submodule update --remote it tells me no changes found


Solution

  • First, make sure to use the latest Git 2.31 or more, because git submodule had some issues before, including when fetching commits.

    Second, try and specify the branch you want your submodule to track

    cd /path/to/your/parent/repo
    git config -f .gitmodules submodule.<path>.branch <branch>
    

    And make sure your submodule is actually at the latest of that branch:

    cd path/to/your/submodule
    git checkout -b branch --track origin/branch
    # if the master branch already exist:
    git branch -u origin/master master
    

    Then try again:

    • Make a new commit in an another cloned repository of Overleaf, and push it
    • Try a git submodule update --remote in the super project.