创建并合并git分支到史诗分支 [英] Create and merge a git branch to an epic branch

查看:90
本文介绍了创建并合并git分支到史诗分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,例如SO / bubbleSort,我需要创建一个名为feature / version-1的史诗分支,因此从这个史诗分支中很少开发人员进行开发,因此,他们需要从史诗分支创建一个单独的分支。我的问题是我们如何合并这些更改,并使史诗分支保持最新的更改。

I am working on a project, for example, SO/bubbleSort and there I need to create an epic branch called feature/version-1 so from this epic branch there are few developers do the development, so for that, they need to create a separate branch from the epic branch. My question is how can we merge those changes and keep the epic branch with the latest changes.

我已按照以下步骤进行操作。

I have followed the following steps to do so. Is it correct?

开发分支的第一步结帐


git结帐开发

git checkout develop

在开发分支下创建一个史诗般的分支

Create an epic branch under the develop branch


git checkout -b Feature / version-1开发

git checkout -b feature/version-1 develop

从史诗分支中为我的开发创建另一个分支

Create another branch for my development from the epic branch


git checkout -b myVersion功能/版本-1

git checkout -b myVersion feature/version-1

实施之后,我需要做什么?

After doing my implementation what do I need to do?

我是否需要从分支到史诗分支提供PR并合并?或者有什么方法可以满足我的需求?

Do I need to give a PR from my branch to the epic branch and merge? OR Is there any way to fulfill my need?

推荐答案


为此,他们需要创建与史诗分支不同的分支

so for that, they need to create a separate branch from the epic branch

不,他们不会,除非他们的每项工作是如此不同,都需要长期的工作

如果没有,他们可以在自己的本地 feature / version-1 分支上工作:

No, they do not, unless each of their work is so different it needs a long-lasting branch of its own.
If not, they can work on their own local feature/version-1 branch:

git fetch
git checkout feature/version-1

这将自动跟踪远程起源/功能/版本1

只是在推送提交之前必须进行重新设置,以便在已经存在的内容之上重新构建其本地工作(在自己的 feature / version-1 分支中进行提交)由该分支上的其他人(在来源/功能/版本-1 中)推送。

They just have to do a rebase before pushing their commit, in order to rebase their local work (commits on in their own feature/version-1 branch) on top of what was already pushed by others on that branch (in origin/feature/version-1).

 git fetch
 git checkout feature/version-1
 git rebase origin/feature/version-1

这样,同步就在本地完成(通过变基)。

然后开发人员在推送之前进行最后一次测试。

That way, the synchronization is done locally (through the rebase). Any merge conflict is resolved there.
Then the developer does one last test before pushing.

OP添加:


在这里,他们的每个工作是如此不同,一个实现取决于另一个人的实现

Here each of their work is so different and the one implementation depends on the other person implementation

然后,是的,将自己的分支推向上游的史诗分支是一个好方法。

但是每个开发人员都需要在强制推动自己的分支之前,将自己的分支重新建立在史诗分支的顶部,以使其工作与史诗分支中接受的内容保持同步。

然后,一旦推动,他们可以执行PR(在第一次推送之后),否则PR将自动更新(在下一个 push --force 之后:由于每个开发人员都是在自己分支上工作的唯一开发人员,他们可以强制推送它,而不会带来负面影响。)

Then yes, pushing their own branch and doing a PR to the upstream epic branch is a good way.
But each developer needs to rebase his/her own branch on top of the epic one before force pushing their own branch, in order to synchronize their work with what was accepted in the epic branch.
Then, once pushed, they can do a PR (after the first push), or the PR will be automatically updated (after the next push --force: since each developer is the only one working on their own branch, they can force push it without negative consequences).

git fetch
git checkout myVersion  
git rebase origin/feature/version-1
git push --force

这篇关于创建并合并git分支到史诗分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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