Git submodule detached head state [duplicate]

浪尽此生 提交于 2019-12-03 22:23:16

问题


I've added 2 submodules to a project, subA and subB, in externals/subA and externals/subB.

Today another team member committed his code and when it is pulled, both subA and subB show detached head status when using git status within externals/subA and externals/subB.

I did git submodule update first and that reported no errors. I tried then git submodule init and git submodule update again but it did not change.

How can we get the submodules back to be in sync? What causes this for the submodules? This is first time problem has arised since we began. Thanks.


回答1:


A submodule is by definition checked out in detached HEAD: it represents a specific SHA1 recorded as a gitlink in the parent repo index.

See "git submodule update" in order to make sure a submodule is tracking a branch:

# add submodule to track master branch
git submodule add -b master [URL to Git repo];

# update your submodule
git submodule update --remote 
# or (with rebase)
git submodule update --rebase --remote


来源:https://stackoverflow.com/questions/48555375/git-submodule-detached-head-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!