git cherry-pick
的-n
选项,这将防止创建提交。git cherry-pick -n commit1
git cherry-pick -n commit3
git commit
同时,您也可以一次挑选多个提交记录:
git cherry-pick -n commit1 commit3
git commit
git checkout master
git cherry-pick commit1
git cherry-pick commit3
git reset HEAD~2 --soft
git commit
git push origin master
进行两次cherry-pick,然后将这两个新的提交压缩成一个:
git checkout master
git cherry-pick commit1
git cherry-pick commit3
git rebase -i @~2
git checkout -b joined
git cherry-pick commit1 commit3
# fix potential merge conflicts
git checkout master
git merge --squash joined