Update a submodule to the latest commit

前端 未结 8 1104
北荒
北荒 2020-12-07 06:54

I have a project A which is a library and it is used in a project B.

Both projects A and B have a separate repository on github BUT inside B we have a submodule of A

8条回答
  •  忘掉有多难
    2020-12-07 07:14

    If you update a submodule and commit to it, you need to go to the containing, or higher level repo and add the change there.

    git status
    

    will show something like:

    modified:
       some/path/to/your/submodule
    

    The fact that the submodule is out of sync can also be seen with

    git submodule
    

    the output will show:

    +afafaffa232452362634243523 some/path/to/your/submodule
    

    The plus indicates that the your submodule is pointing ahead of where the top repo expects it to point to.

    simply add this change:

    git add some/path/to/your/submodule
    

    and commit it:

    git commit -m "referenced newer version of my submodule"
    

    When you push up your changes, make sure you push up the change in the submodule first and then push the reference change in the outer repo. This way people that update will always be able to successfully run

    git submodule update
    

    More info on submodules can be found here http://progit.org/book/ch6-6.html.

提交回复
热议问题