在 Subversion 中,使用“svn merge -r a:b mybranch”很容易 merge 分支中的一系列变更集/差异。但是在 git 中,我发现只能从一个分支中挑选一个提交来将该补丁应用到我当前的工作分支。所以我想知道是否有一种快速的方法可以将错误修复分支中两个标记之间的所有提交一次性应用到我当前的主分支?
最佳答案
执行您正在寻找的操作的最简单方法是使用 git rebase
。这是一个食谱。假设标签 A 是您要选择的补丁系列所基于的提交,而标签 B 是该系列中最后一个补丁的提交。另外,假设 br 是当前分支的名称,也是应该应用新补丁系列的分支。
# Checkout a new temporary branch at the current location
git checkout -b tmp
# Move the br branch to the head of the new patchset
git branch -f br B
# Rebase the patchset onto tmp, the old location of br
git rebase --onto tmp A br
关于git - git patch 分支的子范围的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/509859/