git 如果有多个分支,如何将同一分支推送到同一分支

dkqlctbz  于 2022-11-20  发布在  Git
关注(0)|答案(2)|浏览(125)

我有一个父存储库,它有分支masterstage & develop沿着一个子存储库,比如说子模块,它有相同的分支masterstage & develop,我在子资源库的stage分支中进行了提交(submodule)并尝试将更改推送到父仓库中的stage分支,但更改仍然没有反映在GitHub中。
注意:-它适用于父存储库的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

上面脚本适用于父存储库的master到子存储库的master,就像wise I want适用于父存储库的stage到子存储库的stage一样。

**我甚至尝试使用多个命令:- git push -u原始阶段git config push。默认当前git config push。默认上游

没有一个工作**

vktxenjb

vktxenjb1#

我准备了一个脚本,可以很好地用于分支到分支的提交/推送

################ 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
4xy9mtcn

4xy9mtcn2#

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

相关问题