使用Git将特定提交移动到新分支时出错

时间:2012-11-19 19:00:03

标签: git git-branch git-rebase git-cherry-pick

我有这个:

branch-1     a--b--c--d

我需要这个:

branch-1     a--c--d
branch-2     b

我试过了:

$git checkout -b branch-2
$git cherry-pick <SHA-1 b>

但我得到了这个:

error: could not apply <SHA-1 b>... [comment]
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

所以我做了$git status并得到Unmerged paths ... both modified: .gitignore。我再次尝试git add ed和git commit ted,只是为了再次获得相同的错误消息。

如何将特定提交移动到新分支?

1 个答案:

答案 0 :(得分:0)

当您提交合并时,完成了branch-2的挑选。您不应该再次运行cherry-pick。 Cherry-pick不会改变branch-1的历史记录,所以你需要使用交互式rebase来做到这一点。

相关问题