2014-10-28 112 views
0

有什么复杂的: 我想复制最后提交从“dev”分支到“主”分支。从一个分支git副本提交到另一个

我这样做

git checkout master 
git cherry-pick a6b9463bec0a5240f6e945fbf4951c932751f28d 

,我得到一个错误:

git cherry-pick a6b9463bec0a5240f6e945fbf4951c932751f28d 
error: could not apply a6b9463... releasing v1.00 
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

$ git status 
# On branch master 
# You are currently cherry-picking. 
# (fix conflicts and run "git commit") 
# 
# Unmerged paths: 
# (use "git add <file>..." to mark resolution) 
# 
# both modified:  index.html 
# both modified:  js/boardDims.js 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# config.xml.orig 
no changes added to commit (use "git add" and/or "git commit -a") 

我不明白为什么它是复杂的复制COMIT到另一个分支。 你可以给我命令将这个提交复制到我的主分支吗?

感谢

+0

您是否尝试解决冲突? (提示:'git mergetool') – dug 2014-10-28 20:18:33

+0

是的,但我不明白是什么弹出:有3个文件... – Louis 2014-10-28 20:21:12

+1

不要把它看作3个文件,它基本上是一个文件在3个状态(commit1,commit2 ,解决后) – 2014-10-28 20:22:16

回答

1

您正在运行正确的命令,它在告诉你,你有index.htmljs/boardDims.js冲突的变化。使用diff工具解决冲突,在每个工具上运行git add,最后通过git commit提交合并。

+0

谢谢,你给了我整个过程。 – Louis 2014-10-28 20:31:56

0

这只是“复杂”的,因为当您挑选提交时存在合并冲突。如果来自不同分支的提交改变了通用文件中的同一行,这是正常行为。

您可以了解一些有关解决合并冲突here

1

当你挑樱桃,你复制一个“变”,而不是文件本身。复制更改时,该过程与创建开发分支中最后一次提交的补丁并在主分支上应用该补丁非常相似。如果补丁失败了,Git会告诉你解决它所做的冲突。

虽然大部分时间樱桃采摘是用来抓住一个提交,it can be used to grab a series of commits

要解决冲突,您可以使用git mergetool

Here's a visual explanation of cherry picking。 (向下滚动至底部的幻灯片)

相关问题