简体   繁体   English

Git子模块不进入回购

[英]Git submodules not going into repo

I added a submodule to a feature branch of my local repository. 我在本地存储库的功能分支中添加了子模块。 I can see the related info in .git/config and .gitmodules. 我可以在.git / config和.gitmodules中看到相关信息。 I pushed to the remote. 我推到了遥控器。 git status shows clean. git status显示干净。

When I clone the repo on another box and checkout the branch, I don't see .gitmodules or the entry in .git/config, and thus I cannot build my project as the dependency source code is completely missing. 当我在另一个盒子上克隆仓库并检出分支时,我看不到.gitmodules或.git / config中的条目,因此由于依赖项源代码完全丢失,因此无法构建我的项目。 Do submodules work on branches? 子模块可以在分支上工作吗? What did I do wrong? 我做错了什么?

EDIT: If I git clone -b nameofbranch it DOES check out the .gitmodules file. 编辑:如果我git clone -b nameofbranch它会签出.gitmodules文件。 It doesn't do it if I clone without specifying the branch and then checkout. 如果我克隆时未指定分支然后签出,则不会执行此操作。 Seems like a bug to me but maybe it's intended for some reason I don't understand. 对我来说似乎是个错误,但可能出于某种我不了解的原因。

git clone --recursive is required to recursively clone each submodule. git clone --recursive是递归克隆每个子模块所必需的。 You can accomplish the same with git submodule update in an already cloned repo. 您可以在已经克隆的仓库中使用git submodule update完成相同的操作。

before you push you might have needed this. 在您推动之前,您可能需要这样做。

git submodule foreach git checkout -b origin/branch_name

here branch_name should be the branch to which you are going to push. 在这里,branch_name应该是您要推送到的分支。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM