简体   繁体   English

将不同分支的提交挑选到主分支

[英]Pick Commits from different branches into main branch

I have 3 branches: 我有3个分支:
- master -大师
- feature1 -Feature1
- feature2 -Feature2

Feature1 & Feature2 have common code which is independent and has several commits, How do i pick individual commits from f1 and f2 into master? Feature1和Feature2具有独立的公共代码,并且具有多个提交,如何将f1和f2中的单个提交选入master?

You can use git cherry-pick . 您可以使用git cherry-pick For example, if you wanted to copy a commit from feature1 whose hash was a43kbjhl to master , you could do the following: 例如,如果要将提交从feature1哈希为a43kbjhl的提交复制到master ,则可以执行以下操作:

git checkout master
git cherry-pick a43kbjhl

And you can repeat the above step for all the commits you want to cherry pick. 然后,您可以对所有您想要挑选的提交重复上述步骤。 Keep in mind that if you actual inspect the commits you have copied over, their SHA-1 hashes actually won't match the originals. 请记住,如果您实际检查已复制的提交,则它们的SHA-1哈希实际上将与原始不匹配。 This is because Git has created new commits for each cherry-pick. 这是因为Git为每个樱桃选择创建了新的提交。

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

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