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

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

问题描述

我有 BranchA,它比 BranchB 早 113 次提交.

I have BranchA which is 113 commits ahead of BranchB.

但我只希望 BranchA 的最后 10 个提交合并到 BranchB.

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

有没有办法做到这一点?

Is there a way to do this?

推荐答案

git cherry-pick 命令允许您进行一次提交(从任何分支),并且基本上,在您的工作分支中对其进行变基.

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

Pro Git 书的第 5 章解释它比我能做的更好,并附有图表等.(关于 Rebase 的章节 也很好读.)

Chapter 5 of the Pro Git book explains it better than I can, complete with diagrams and such. (The chapter on Rebasing is also good reading.)

最后,有一些关于cherry-picking vs merging vs rebase in的好评论另一个 SO 问题.

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

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