Git合并测试分支(最终提交)到master分支 [英] Git merge testing branch (final commit) to master branch

查看:1972
本文介绍了Git合并测试分支(最终提交)到master分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个测试分支。它有很多微小的提交来构建一个功能。
在结尾处,我想完成最终的更改,并将它们放到主分支中。

主分支不应包含测试分支的历史记录。
测试分支最终将被移除。

I have created a testing branch. It has a lot of tiny commits to build one feature. At the end of it, I want to take the final completed changes, and put them into the master branch.
The master branch, shouldn't contain the history of the testing branch.
Testing branch will be removed eventually.

实现此目的的最佳方法是什么?

将生成补丁并应用它的主人是最好的方式?

如果是这样,我该如何生成/应用补丁?

What is the best way to achieve this?
Would generating a patch and applying it on master be the best way?
If so, how do I generate/apply the patch?

推荐答案

< <了解Git工作流程中介绍了各种方法:


绝大多数时候,我的清理只是一个压扁合并。

The vast majority of the time, my cleanup is just a squash merge.



git checkout master
git merge --squash private_feature_branch
git commit -v



更大的工作



Larger work


我决定改变我们可以分解成更小的变化,所以南瓜太钝了。 (作为一个经验法则,我会问,这是否容易进行代码审查?)

I decide my change should be broken into smaller changes, so squash is too blunt an instrument. (As a rule of thumb I ask, "Would this be easy to code review?")

git rebase --interactive master

git rebase --interactive master

(在您的案例中不是一个选项,就像您在您的问题中提到的那样)

宣布分行破产



(not an option in your case, as you mention in your question)


也许我的功能分支存在了很长一段时间,我不得不将几个分支合并到我的功能分支中,以便在工作时保持最新状态。历史是错综复杂的。

最简单的方法是抓住原始差异创建一个干净的分支。

Maybe my feature branch existed for a very long time, and I had to merge several branches into my feature branch to keep it up to date while I work. History is convoluted.
It’s easiest to grab the raw diff create a clean branch.



git checkout master
git checkout -b cleaned_up_branch
git merge --squash private_feature_branch
git reset




我现在有一个工作目录,里面充满了我的更改,没有一个来自上一个分支的行李。现在我手动添加并提交我的更改。

I now have a working directory full of my changes and none of the baggage from the previous branch. Now I manually add and commit my changes.

这篇关于Git合并测试分支(最终提交)到master分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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