如何将某些提交合并到另一个分支

时间:2016-04-13 16:02:32

标签: git

这是我的情况

master commit1 commit2 develop commit3 commit4 fix

我想创建从master派生的新分支,并添加commit3和commit4。

我试过了:

git checkout master
git checkout -b master1
git rebase --onto master develop master1

但没有成功

1 个答案:

答案 0 :(得分:0)

回到上一个已知的良好版本的master(例如6个提交前):

git reset HEAD~6 

创建一个新分支:

git checkout -b newmaster

坚持良好的承诺:

git cherry-pick commit3
git cherry-pick commit4