简体   繁体   English

GIT Checkout-开关子模块

[英]GIT Checkout - Switch Submodules

I have a project with a master and staging branch. 我有一个具有master暂存分支的项目。 The project has a submodule which also had a master and staging branch. 该项目具有一个子模块,该子模块还具有一个masterstaging分支。

My .gitmodules file has referenced the branch correctly so eg my project on branch master has the following 我的.gitmodules文件正确引用了该分支,因此例如,我在分支母版上的项目具有以下内容

[submodule "src/mysubmodule"]
    path = src/mysubmodule
    url = https://username@bitbucket.org/username/mysubmodule.git
    branch = master

and the branch staging has 并且分支阶段

[submodule "src/mysubmodule"]
    path = src/mysubmodule
    url = https://username@bitbucket.org/username/mysubmodule.git
    branch = staging

I want to switch the branch of my submodule(s) as well if i switch the branch of my project. 如果要切换项目的分支,我也想切换子模块的分支。 git checkout master etc. git checkout master

The submodule.<id>.branch configuration is just a hint for git submodule update --remote or ... --rebase . submodule.<id>.branch配置只是git submodule update --remote... --rebase It will be ignored by the default --checkout operation. 默认--checkout操作将忽略它。

You have to update the submodules of the "staging" branch manually (eg by git submodle update --remote ) and commit these changes then. 您必须手动更新“ staging”分支的子模块(例如,通过git submodle update --remote ),然后提交这些更改。

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

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