Git:将本地分支合并到远程分支A和B,而无需将代码从A插入B/B到A [英] Git: Merge local branch to remote branches A and B without inserting code from A into B/ B into A

查看:344
本文介绍了Git:将本地分支合并到远程分支A和B,而无需将代码从A插入B/B到A的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用的存储库有3个分支:Master,Demo和Development.经过适当测试的事物从开发变成了演示.演示之后,它将进入主服务器,然后进行部署.

The repository I am working with has 3 branches: Master, Demo, and Development. Things that have been properly tested go from Development into Demo. After Demo, it goes into Master and then deployed.

在进行更改时,我从Demo分支(具有最新功能的最稳定的分支)中拉出,并创建一个本地分支.

When working on changes, I pull from the Demo branch, the most stable branch with newest features, and create a local branch.

要进行更改以进行测试,我需要将其合并到Development分支中.但是并不是Development分支上的所有内容都准备好进入Demo分支.

To put my changes for testing I need to merge them into the Development branch. But not everything on the Development branch is ready to go into the Demo branch.

有没有一种方法可以将更改合并到Development分支中,如果我的更改确定,然后将我的分支合并到Demo分支中,但无需从Development引入任何代码?

Is there a way I can merge my change into the Development branch, where if my change is OK'd, I then merge my branch into the Demo branch, but without bringing in any of the code from Development?

很抱歉,如果这是一个初学者的问题并且标题令人困惑.

Apologies if this is a beginner question and confusing title.

推荐答案

是的,您可以在合并dev之前对其进行测试:

yes, you can test your dev branch before merge it:

1)创建一个分支,例如:task1: git checkout -b task1

1) create a branch ex: task1: git checkout -b task1

2)完成这些更改后,提交并推送到该分支

2) when you're done with these changes, commit and push into this branch

3)然后执行合并请求(gitlab概念)或拉取请求(github概念)

3) then do a merge request (gitlab concept) or pull request (github concept)

4)现在是时候在本地测试此分支了:

4) now its time to test this branch locally :

4-1) git fetch origin

4-2) git checkout -b task1 origin/task1

5)现在,您可以在本地查看更改,如果可以,请尝试将其合并:

5) now you are able to view changes locally, if ok then try to merge it :

5-1)

git fetch origin
git checkout origin/master

5-2)合并此分支:

5-2) merge this branch:

git merge --no-ff task1

解决冲突并更正错误(如果存在),然后将完美的版本推送到您的分支ex中:master:

resolve conflict and correct error if exist then push this version if is perfect into your branch ex : master:

git push origin master

如果您与显示的头条消息分离,则请执行以下操作:

if you are detached from head message shown then do this instead :

git push origin HEAD:master

这篇关于Git:将本地分支合并到远程分支A和B,而无需将代码从A插入B/B到A的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆