How to revert a Git Submodule pointer to the commit stored in the containing repository?

前端 未结 7 1223
感动是毒
感动是毒 2021-01-29 22:44

I have a git submodule in my main git repo. As I understand it, the main repo stores a SHA value (somewhere...), pointing to the specific commit of the submodule that it is \"li

7条回答
  •  不要未来只要你来
    2021-01-29 23:13

    You want to update your submodule so it is in sync with what the parent repository believes it should be. This is what the update command is for:

    From the submodule manpage:

    Update the registered submodules, i.e. clone missing submodules and
    checkout the commit specified in the index of the containing
    repository. This will make the submodules HEAD be detached unless
    --rebase or --merge is specified or the key submodule.$name.update
    is set to rebase or merge.
    

    Run this and all should be well:

    git submodule update --init
    

    You can add the --recursive flag as well to recurse through all submodules.

提交回复
热议问题