git submodule checks out the same commit

前端 未结 4 1955
一整个雨季
一整个雨季 2021-01-15 05:34

After I git submodule update it always checks out the same commit. for example 34561.

I do git checkout master for submodule a

4条回答
  •  深忆病人
    2021-01-15 05:50

    The 'main' project contains a reference to the SHA-1 of the checked out version each submodule. This is part of the commit in the main project.

    If you change the head of a submodule manually in the submodule, you need to tell the main project that from now on it should use this SHA-1 for the submodule.

    git commit -a
    

    will do this, as the main project will see the submodules head was updated.

    This may be surprising, but it is actually a nice feature. With checking in the head in the main project, you basically tell your colleagues that it is now ok to use the newer version of the submodule. This allows people to work together without too much risk of pulling the rug under others feet.

    (That being said, there are many warts in a workflow with submodules, and you probably should agree an approach and the cement it with some team scripts to avoid the pitfalls).

提交回复
热议问题