Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
534 views
in Technique[技术] by (71.8m points)

git - 如何挑选多个提交(How to cherry-pick multiple commits)

I have two branches.

(我有两个分支。)

Commit a is the head of one, while the other has b , c , d , e and f on top of a .

(提交a是一个的头,而其他有bcdef之上a 。)

I want to move c , d , e and f to first branch without commit b .

(我想将cdef移到第一分支而不提交b 。)

Using cherry pick it is easy: checkout first branch cherry-pick one by one c to f and rebase second branch onto first.

(使用樱桃挑选很容易:以cf逐个签出第一个分支樱桃选择,然后将第二个分支重新设置为第一个分支。)

But is there any way to cherry-pick all c - f in one command?

(但是,有什么方法可以在一个命令中挑选所有c - f吗?)

Here is a visual description of the scenario (thanks JJD ):

(这是该场景的直观描述(感谢JJD ):)

在此处输入图片说明

  ask by tig translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Git 1.7.2 introduced the ability to cherrypick a range of commits.

(Git 1.7.2引入了选择一系列提交的功能。)

From the release notes :

(从发行说明中 :)

git cherry-pick" learned to pick a range of commits (eg "cherry-pick A..B" and "cherry-pick --stdin"), so did "git revert"; these do not support the nicer sequencing control "rebase [-i]" has, though.

(git cherry-pick”学会了选择一系列提交(例如“ cherry-pick A..B”和“ cherry-pick --stdin”),“ git revert”也是如此;它们不支持更好的排序控制“重新设置[-i]”。)


Including important comments (credits to respective authors)

(包括重要评论(对各自作者的感谢))

Note 1: In the "cherry-pick A..B" form, A should be older than B. If they're the wrong order the command will silently fail.

(注意1:在“ cherry-pick A..B”格式中,A应该早于B。如果输入的顺序错误,该命令将自动失败。)

– damian

(–达米安)

Note 2: Also, this will not cherry-pick A, but rather everything after A up to and including B. – JB Rainsberger

(注意2:此外,这不会选择A,而是选择从A到B(包括B)之后的所有内容。– JB Rainsberger)

Note 3: To include A just type git cherry-pick A^..B – sschaef

(注意3:要包含A,只需键入git cherry-pick A ^ .. B – sschaef)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...