2017-01-23 74 views

回答

2
git checkout master 
git cherry-pick commit1 
git cherry-pick commit3 
git reset HEAD~2 --soft 
git commit 
git push origin master 

更新:改变HEAD^2到HEAD〜2

+0

“HEAD^2”< - 你的意思是HEAD〜2? – jbu

+0

@jbu是的。谢谢。我犯了一个错误。 – ElpieKay

0

做两樱桃选秀权,然后压扁了两个新的提交:

git checkout master 
git cherry-pick commit1 
git cherry-pick commit3 
git rebase -i @~2 

在编辑器中,选择 “挤压” 了第二次提交。根据自己的喜好编辑提交消息。

1

您可以简单地使用git cherry-pick-n选项,该选项可防止创建提交。

git cherry-pick -n commit1 
git cherry-pick -n commit3 
git commit 

您也可以摘樱桃多次提交一次:

git cherry-pick -n commit1 commit3 
git commit 
+0

我认为'-n'选项可能会有问题,如果您必须解决任何樱桃选择合并冲突。 – Mort

相关问题