Search code examples
githerokugit-submodules

heroku doesn't update submodules after push


I have an app hosted on heroku contaiting a submodule. The submodule contains multiple submodules. The submodules are in form of http address to github repo.

app
 |- submodule1
 |- other dirs

submodule1
 |- submodule2
 |- submodule3
 |- other dirs

I made changes in several sobmodules then commited everything (including submodules) and pushed to github. I can verify, that submodules point to the correct commits i.e. a repo may be obtained via git clone --recursive ....

After I pushed to github, I pushed to heroku. The app itself updated, nevertheless the submodules remained the same (even though they are commited and pushed to github)!

Example of .gitmodules:

[submodule "src/main/java/runtime"]
    path = src/main/java/runtime
    url = https://github.com/USER/REPO.git

What should I do? This is serious problem for me.


Solution

  • Git treats a submodule like a separate repository with regard to pushing to a remote. The correct procedure here would be to push each submodule, then push the submodule containing the submodules, and finally push your root project. So you would want to do something like this:

    cd app/submodule1/submodule2/
    git commit -m                  # commit files in submodule2
    git push                       # push to repository
    
    ...                            # do the same for all other submodules in submodule1
    
    cd app/submodule1/
    git commit -m                  # commit files in submodule1
    git push                       # push to repository
    

    And finally:

    cd app/                        # change to directory of main project
    git commit -m                  # commit files in main project
    git push                       # after this everything will be up to date