git修补分支的子范围的最佳方法是什么? [英] What is the best way to git patch a subrange of a branch?
问题描述
执行您正在查找的操作的最简单方法是使用 git rebase
。这是一个配方。假设标签A是您要选择的补丁系列的顶层提交,并且标签B是系列中最终补丁的提交。另外,假设br是当前分支的名称,以及应该应用新补丁系列的分支。
#结帐在当前位置的新临时分支
git checkout -b tmp
#将br分支移动到新的补丁集的头部
git分支-f br B
#将补丁集重新加入到tmp中,旧的位置为br
git rebase - tmp A b
In Subversion, it is easy to merge a range of changesets/diffs from a branch using "svn merge -r a:b mybranch". But in git, I found it is only possible to cherry-pick a single commit from a branch to apply that patch to my current working branch. So I am wondering if there is a fast way to apply all the commits in one swoop between two tags in a bugfix branch to my current master branch?
The easiest way to perform the action that you are looking for is with git rebase
. Here's a recipe. Assume that tag A is the commit on top of which the patch series that you want to select is based and that tag B is the commit of the final patch in the series. Also, assume that br is the name of the current branch and the branch where the new patch series should be applied.
# 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修补分支的子范围的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!