A rebase --onto如果在集成分支的顶部重放给定的提交范围,将更好,如查尔斯·贝利.(此外,请查找“这里是如何基于一个分支将主题分支移植到另一个分支”的git重基手册页的实际例子git rebase --onto)如果您当前的分支是集成的,那么:# Checkout a new temporary branch at the current locationgit checkout -b tmp# Move the integration branch to the head of the new patchsetgit
branch -f integration last_SHA-1_of_working_branch_range# Rebase the patchset onto tmp, the old location of integrationgit rebase --onto
tmp first_SHA-1_of_working_branch_range~1 integration它将在以下几个方面重播所有内容:在父母之后first_SHA-1_of_working_branch_range(因此~1):你想要重播的第一次提交直至“integration“(指向要重播的最后一次提交,从working支部)致“tmp“(指的是integration指过去)如果其中一次提交被重播时有任何冲突:要么解决它,然后运行“git rebase --continue".或者跳过此修补程序,而是运行“git rebase --skip"或者用“git rebase --abort“(然后放回integration支线tmp支部)在那之后rebase --onto, integration将返回到集成分支的最后一次提交(即“tmp“分支+所有重放提交)摘樱桃或者rebase --onto,不要忘记它对随后的合并有影响,如在此描述.纯“cherry-pick“并涉及以下内容:如果您想使用修补程序的方法,那么“git格式-修补程序\git是”和“git樱桃”是您的选择。目前,git cherry-pick只接受一次提交,但如果要选择范围B贯通D那就是B^..D用吉特林戈语,所以git rev-list --reverse --topo-order B^..D | while read rev
do
git cherry-pick $rev || break done但是无论如何,当您需要“重放”一系列提交时,“重播”一词应该促使您使用rebase“Git的特征。