3 回答
TA贡献1906条经验 获得超10个赞
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的特征。
TA贡献1826条经验 获得超6个赞
git cherry-pick
学会选择一系列的提交(例如: cherry-pick A..B
和 cherry-pick --stdin
),也是 git revert
这些不支持更好的测序控制。 rebase [-i]
尽管如此。
TA贡献1796条经验 获得超7个赞
git format-patch A..B git checkout integration git am *.patch
--3way
git-am
- 3 回答
- 0 关注
- 935 浏览
添加回答
举报