使用 Git 将未合并的功能分支合并到另一个功能分支中 [英] Merge non-merged feature branch into another feature branch with Git

查看:39
本文介绍了使用 Git 将未合并的功能分支合并到另一个功能分支中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我公司的 Git 工作流程如下所示:

My company has a Git workflow that looks something like this:

  • 从原始分支创建功能分支(我们使用名为develop"的基础分支,但您可以将其视为master")
  • 在此功能分支中完成您需要完成的工作,并提交您的更改
  • 有时,使用开发分支重新定义您的功能分支
  • 当您的功能分支中的工作完成后,提交并推送到 GitHub 上的远程功能分支
  • 创建拉取请求以将您的功能分支合并到开发分支中,从而让另一位开发人员审查代码
  • 代码审查完成后,将feature分支合并到develop分支,删除feature分支

这适用于处理串行工作流程的情况,但是当您从功能分支推送更改并等待其他开发人员审查和合并您的更改时,您可能想要接受另一部分工作,这意味着重复上述过程.

This works when you're dealing with a serial workflow, but when you've pushed your changes from your feature branch and are waiting on the other developer to review and merge your changes, you probably want to take on another piece of work, which means repeating the above process.

在我们的例子中,我们目前正在从 develop 分支创建我们的特性分支,所以我刚刚完成的工作还没有可用(它仍然处于不确定状态,等待另一个开发人员合并到 develop 分支中).我的问题是,如果我在我的 new 功能分支中所做的工作取决于我刚刚在上一个功能分支中完成的工作怎么办?我应该最初从我尚未合并的功能分支而不是开发分支分支我的新功能分支吗?如果我已经从开发分支创建了我的新功能分支,那么从未合并的分支中获取我缺少的更改就像在我的新分支中执行 git merge [unmerged-branch] 一样简单?

In our case, we're currently creating our feature branches from the develop branch, so the work I just completed isn't yet available (it's still in limbo, waiting to be merged into the develop branch by another developer). The question I have is, what if the work I'm doing in my new feature branch depends on the work I just completed in my previous feature branch? Should I be initially branching my new feature branch from my as-of-yet unmerged feature branch instead of the develop branch? If I've already created my new feature branch from the develop branch, is getting the changes I'm missing from the unmerged branch as simple as doing a git merge [unmerged-branch] within my new branch?

希望这个解释——以及工作流程本身!- 说得通.我陷入了一些奇怪的情况,我不清楚代码的状态,所以我试图找出一个工作流程,让我可以灵活地合并来自其他功能分支的更改,同时仍然可以随时获取上游更改时间.

Hopefully this explanation -- as well as the workflow itself! -- makes sense. I've gotten myself into some weird situations where I'm unclear the state of my code, so I'm trying to figure out a workflow that gives me the flexibility to merge in changes from other feature branches while still getting upstream changes at any time.

推荐答案

我的问题是,如果我在我的新功能中所做的工作分支取决于我刚刚在上一个功能中完成的工作分支?我应该最初从我的分支中分支我的新功能分支吗?尚未合并的功能分支而不是开发分支?

The question I have is, what if the work I'm doing in my new feature branch depends on the work I just completed in my previous feature branch? Should I be initially branching my new feature branch from my as-of-yet unmerged feature branch instead of the develop branch?

按照你描述的方式,是的,你会的.但是,我担心可能会走上未批准/未审查"工作的道路,就好像您的代码审查导致重大更改一样,您可能会发现自己需要重做大量工作.

The way you're describing it, yes, you would. However, I'd be concerned about potentially going down the path of working off of "unapproved / unreviewed" work, as if your code review results in significant changes, you may find yourself redoing a lot of work.

如果我已经从开发分支创建了我的新功能分支,正在从未合并的分支中获取我遗漏的更改很简单就像在我的新分支中执行 git merge [unmerged-branch] 一样?

If I've already created my new feature branch from the develop branch, is getting the changes I'm missing from the unmerged branch as simple as doing a git merge [unmerged-branch] within my new branch?

是的.应该.:)

这篇关于使用 Git 将未合并的功能分支合并到另一个功能分支中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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