简体   繁体   English

如何将提交从一个分支复制到另一个分支?

[英]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 ). 我的master分支中有4个提交,但我想将它们复制并放入另一个分支( branch2 )中。

Can I do this with cherry pick and if yes how can I? 我可以用樱桃挑选吗?如果可以,我该怎么办?

Yes cherry-pick is what you want here. cherry-pick是你想要的这里。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将提交从一个分支复制到另一个分支 - How to copy commits from one branch to another 如何将提交从一个分支复制到另一个分支? - How to copy commits from one branch to another? 如何创建一个兄弟分支,其中包括从另一个分支到一个节点的所有提交? - How can I create a sibling branch that includes all the commits from another branch into one node? 如何将我的所有文件还原到另一个分支的早期提交之一? - How can I revert all my files back to one of an earlier commits from another branch? 如何查看从一个分支到另一个分支的提交 - How to see the commits from one branch to another 如何将所有文件和文件夹从一个分支替换/复制到GIT中的另一个现有分支 - How Can I replace/copy all file and folder from one branch to another existing branch in GIT 我可以将推送的提交从一个分支移动到另一个现有分支吗? - Can I move pushed commits from one branch to another existing branch? git-svn:如何将git提交从一个SVN分支复制到另一个SVN分支? - git-svn: how to copy git commits from one SVN branch to another? 如何将基于分支的提交合并到另一个分支? - How can I merge branch-based commits into another branch? 如何将一个分支(或指定的提交)移动到另一个分支? - How can I move a branch ( or specified commits) to another branch?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM