[英]git submodule checked out in the wrong branch
In my git repository I have two branches master
and legacy
. 在我的git仓库中,我有两个分支master
和legacy
。 I have added the following .gitmodules
file to my legacy branch. 我已经将以下.gitmodules
文件添加到我的旧版分支中。 master
branch does not have a .gitmodules
file.However the git submodule is getting checked out in master
branch. master
分支没有.gitmodules
文件。但是git子模块正在master
分支中签出。 In the legacy
branch nothing is getting checked out. 在legacy
分支中,没有任何内容被检出。
My .gitmodules file . 我的.gitmodules文件。
[submodule "build"]
path = build
url = git@git.gitlabs.com:Karthik.Sharma/build.git
branch = 0.4
What am I doing wrong? 我究竟做错了什么?
First, after adding the .gitmodules files, you should make a git submodule update --init
in order to force the submodule to be checked out. 首先,在添加.gitmodules文件之后,您应该进行git submodule update --init
,以强制检出该子模块。
Second, check the nature of the build
folder in the master branch. 其次, 检查 master分支中build
文件夹的性质 。
git ls-files --stage | grep 160000
If you don't see build
in the result, that means it is a regular folder (not a submodule). 如果在结果中看不到build
,则表示它是常规文件夹(而不是子模块)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.