submodule切换分支_git子模块分支会随主项目的分支切换吗?
Recently I got to know git submodules. They appear to be self-sufficient projects with their own git structure and branches.
When I switch main project's branch, does this also switch submodule's branch? How does git handle this situation?
解決方案
I recently came across a similar question. (I'll let you read the content of this answer as it gives you the background to my answer).
A submodule is just a reference to a repo and a commit in this repo.
When you switch branch, the reference may change (if the branch you're switching to uses a different reference) but the filesystem of the submobule will remain untouched.
So writing git status will yield a result showing that your submodule status differs from the one in your current HEAD.
To make the submodule point to the right commit for HEAD, simply invoke:
$ git submodule update
In addition, the branch of your submodule is not interesting to the enclosing repo as the reference is always added toward a commit and not toward a branch. The branches in your submodule will therefore only reflect your branching strategy for the submodule and do not need to match the enclosing repository's branching strategy.
總結(jié)
以上是生活随笔為你收集整理的submodule切换分支_git子模块分支会随主项目的分支切换吗?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: pgsql数据库默认配置事务类型_Pos
- 下一篇: dd linux 格式化u盘启动盘_li