2

I have 4 commits in my master branch but I want to copy them and put into a another branch (branch2).

Can I do this with cherry pick and if yes how can I?

Calum Halpin
  • 1,945
  • 1
  • 10
  • 20
jeremy
  • 165
  • 10
  • 3
    Possible duplicate of [How do I move a commit between branches in Git?](https://stackoverflow.com/questions/3710192/how-do-i-move-a-commit-between-branches-in-git) – Pavel Anikhouski Jul 30 '19 at 13:10

1 Answers1

1

Yes cherry-pick is what you want here. If the commits are consecutive:

git checkout branch2
git cherry-pick <commit-1-id>..<commit-4-id>

Otherwise you will have to specify them individually:

git cherry-pick <commit-1-id> <commit-2-id> <commit-3-id> <commit-4-id>
Calum Halpin
  • 1,945
  • 1
  • 10
  • 20