我有一个有分支的父存储库master
stage
&develop
与子存储库一起表示为子模块它有相同的分支master
stage
&develop
,我在stage
分支在子存储库(子模块)中进行了提交。),并尝试将更改推送到父库中的stage
分支,但更改仍然没有反映在GitHub中。
注意:-它适用于父repo的master
到子repo的master
。**脚本用于master* *
#!/bin/bash
git init
git clone --recurse-submodules https://github.com/username/file.git
cd file
git submodule update --remote
git commit -a -m "commit in both submodule"
git push -u origin
以上脚本同样适用于父repo的master
到子repo的master
我想为父repo的stage
子repo的stage
以及。
**我甚至尝试使用多个命令:-Git push -u origin stageGit配置push.default currentGit config push.default upstream
他们都不工作* *
我准备了一个脚本,可以很好地用于分支间的提交/推送
################ STAGE
#########################################
#!/bin/bash
#git init
git init
#git clone repo stage including submodules
git clone -b stage --recurse-submodules git@github.com:orgs/file.git
#change directory -repo
cd file
#update the remote ie tag/commits
git submodule update --remote
#add commit
git commit -a -m "commit in stage submodules"
#git push
git push -u origin stage
git init
+ git clone
意味着你在一个新的本地Git存储库中克隆一个嵌套的Git存储库(及其潜在的子模块)。
我不推荐这种方法。
:
-
直接在正确的分支克隆您的存储库:
git clone -b stage --recurse-submodules git@github.com:orgs/file.git cd file git submodule update --remote
-
然后进入父存储库文件中所需的子模块
cd aSubmodule (check your `file/.gitmodules` file for the list of submodules you currently have) git switch stage # work, add, commit push
-
然后返回到名为'file'的主父存储库,并记录新的子模块状态
cd .. # add, commit and push