简体   繁体   中英

How can I copy commits from one branch to another?

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM