Search code examples
gitgit-submodulesgit-merge

How to update git submodule


I have just done a git merge <merging_branch_name> in the app and resolved many conflicts.

But when I do git status, I can see list of submodules with (new commits) in the message. It looks like the submodule (branch/tag) versions have not been updated.

For example:

modified:   plugins/myplugin.git (new commits)

How do I update the submodules with the versions (with the <merging_branch_name>)

I get like this in git bash

my_app (current_branch  |MERGING), 

so when I do git status, I get list of submodules as below

 modified:   plugins/plugin1.git (new commits)
 modified:   plugins/plugin2.git (new commits)
 modified:   plugins/plugin3.git (new commits)
 modified:   plugins/plugin4.git (new commits)

How do I solve this?


Solution

  • To update a submodule content to the new SHA1, this should be enough:

    # the submodule content needs to be updated
    git submodule update --init
    
    # the parent repo needs to record the new submodule SHA1
    git add plugins/myplugin