如何在Git中将特定的提交从一个分支合并到另一个分支? [英] How do I merge a specific commit from one branch into another in Git?

查看:134
本文介绍了如何在Git中将特定的提交从一个分支合并到另一个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 BranchA ,它是113 BranchB 之前的提交。



但我只希望从 BranchA 中的最后10次提交合并到 BranchB 中。



有没有办法做到这一点?

解决方案 git cherry-pick< commit> 命令允许你从一个分支中进行一次单独的提交,本质上, b $ b

第5章Pro Git书会比我更好地解释它,并附有图表等。查找标题为重新激活和樱桃采摘工作流程的部分。 (关于Rebasing的章节也很好。)



最后,有一些好评樱桃采摘vs合并与另一个SO问题的重组


I have BranchA which is 113 commits ahead of BranchB.

But I only want the last 10 or so commits from BranchA merged into BranchB.

Is there a way to do this?

解决方案

The git cherry-pick <commit> command allows you to take a single commit (from whatever branch) and, essentially, rebase it in your working branch.

Chapter 5 of the Pro Git book explains it better than I can, complete with diagrams and such; look for the section entitled "Rebasing and Cherry Picking Workflows". (The chapter on Rebasing is also good reading.)

Lastly, there are some good comments on the cherry-picking vs merging vs rebasing in another SO question.

这篇关于如何在Git中将特定的提交从一个分支合并到另一个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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