Update Git submodule to latest commit on origin

后端 未结 14 1501
清歌不尽
清歌不尽 2020-11-27 09:02

I have a project with a Git submodule. It is from an ssh://... URL, and is on commit A. Commit B has been pushed to that URL, and I want the submodule to retrieve the commit

14条回答
  •  萌比男神i
    2020-11-27 09:34

    In your project parent directory, run:

    git submodule update --init
    

    Or if you have recursive submodules run:

    git submodule update --init --recursive
    

    Sometimes this still doesn't work, because somehow you have local changes in the local submodule directory while the submodule is being updated.

    Most of the time the local change might not be the one you want to commit. It can happen due to a file deletion in your submodule, etc. If so, do a reset in your local submodule directory and in your project parent directory, run again:

    git submodule update --init --recursive
    

提交回复
热议问题