1

I have one local commit (for example, at branch1 branch) and I need to apply it to another branch (eg. branch2). I know that I have to use the

git cherry-pick

command but I really cant find out by myself how the command should finally look. Help me please and sorry for my English.

UPD: I've read this link, but I still cant understand how to use it in my case.

SeniorJD
  • 6,946
  • 4
  • 36
  • 53

1 Answers1

1

git cherry-pick should be as easy as:

git checkout targetBranch
git cherry-pick <SHA1>

(with <SHA1> the SHA1 of the commit you want to apply)

In your case:

git checkout branch2
git cherry-pick branch1

See this blog post or this post for example.

You have more illustrations in "CHERRY-PICKING EXPLAINED":

http://think-like-a-git.net/assets/images2/reachability-example.png

If you were at node H in this graph, and you typed git cherry-pick E (yes, you'd actually type part or all of the SHA for the commit, but for simplicity's sake, I'll just use the labels that are already here), you'd wind up with a copy of commit E—let's call it "E prime" or E'—that pointed to H as its parent, like so:

http://think-like-a-git.net/assets/images2/cherry-pick-example-1.png

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250