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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“了解 Git 工作流程”中描述了各种方法:
短暂的工作
更大的工作
git rebase --interactive master
(在你的情况下不是一个选项,正如你在问题中提到的)
宣布分支机构破产
Various approaches are described in "Understanding the Git Workflow":
Short lived work
Larger work
git rebase --interactive master
(not an option in your case, as you mention in your question)
Declaring Branch Bankruptcy
您正在寻找
git merge
的--squash
选项:所以 git merge --squash test-branch 并提交。
您也可以尝试 git merge --no-commit --no-ff test-branch
You are looking for
--squash
option ofgit merge
:So
git merge --squash test-branch
and commit away.You may also try
git merge --no-commit --no-ff test-branch
--squash
会将您的工作集置于这样的状态,就好像测试分支上的所有更改都已合并到 master 中,但不会创建任何提交。然后,您可以执行 git commit ,所有更改都将在一次提交中进行。That
--squash
will put your working set in the state as if all the changes on testing-branch got merged in with master, but won't create any commits. You can then dogit commit
and all the changes will go in in a single commit.