2014-10-28 111 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。 (向下滾動至底部的幻燈片)

相關問題