0

Git version 1.7.1 - CentOS 6.6

I am trying to cherry pick a range of commits.

I am in my feature branch and the output of git log is like below

commit: 111
Author: abc
time: xyz

commit: 222
Author: abc
time: xyz

commit: 333
Author: abc
time: xyz

commit: 444
Author: abc
time: xyz

commit: 555
Author: abc
time: xyz

And I go back to master branch to pick a few commits from feature branch.

I want to cherry pick from 444 to 222. So i pass the below command:

git cherry-pick 444^..222

But I get an error like below:

fatal: Cannot find '444^..222'

However, I can cherry pick a single commit. I'm pretty sure that my syntax is correct. I want to include commits 444,333 and 222 to apply in my target branch.

I can successfully do git show for both the commits. Where am I going wrong?

Bala Krishnan
  • 374
  • 3
  • 18
  • 1
    you don't want cherrypick you want `rebase --onto master 555 222`. add `-i` for *interactive mode* for more control. – Timothy Truckle Jul 09 '18 at 12:59
  • Will it just merges/copies only the files in those commits? Or will it merge the entire history? Also I am not going to merge both the branches forever! – Bala Krishnan Jul 09 '18 at 13:09
  • *"Will it just merges/copies only the files in those commits?"* sort of, it only copies the *changes* made in this commits. – Timothy Truckle Jul 09 '18 at 13:11
  • *"lso I am not going to merge both the branches forever!"* what does that mean? – Timothy Truckle Jul 09 '18 at 13:11
  • I will not merge the feature branch with master for any reason in future. In that case cherrypick is better? – Bala Krishnan Jul 09 '18 at 13:14
  • 1
    *"In that case cherrypick is better?"* there is no difference. in both cases the changes become new commits in the target branch. However, git is smart enough to avoid conflicts with cherrypicked/rebased commits. – Timothy Truckle Jul 09 '18 at 13:17
  • Okay. But few forums say that cherry picking is not good since it creates a new commit # and it is against the principles of versioning... anyway I will go with cherry picking! Thank you very much! :) – Bala Krishnan Jul 09 '18 at 13:56

1 Answers1

1

Git version 1.7.1 does not support cherry-picking a range of commits. That feature first appeared in Git 1.7.2.

(But any version of Git predating about 2.7 at this point is ancient and you should upgrade.)

torek
  • 448,244
  • 59
  • 642
  • 775
  • Okay I actually found it myself and yeah you are right. But in CentOS 6.x version 1.7.1 is the highest through yum repo. But I tried with CentOS 7 and found it working. Thanks for the answer! – Bala Krishnan Jul 09 '18 at 13:53