我有两个分支Z,一些已更改,M有一些相互矛盾的变化.我想将Z上的第一个更改合并到M.当我试图看到哪些更改仍在那里时.(实际上还有一些更改,但这已经显示了问题)
$ git checkout M
$ git cherry M Z
+ 153c2f840f2192382be1fc435ceb069f0814d7ff
+ 4a7979d5dd526245b51769db21acf4c286825036
$ git cherry-pick 153c2f840f2192382be1fc435ceb069f0814d7ff
error: could not apply 153c2f8... add Z
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'
• (M|CHERRY-PICKING) $ git st
# On branch M
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: README.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
• (M|CHERRY-PICKING) $ vim README.txt
Run Code Online (Sandbox Code Playgroud)
我在这里解决了冲突
• (M|CHERRY-PICKING) $ git add README.txt
• (M|CHERRY-PICKING) $ git ci -m'cherry picked'
[M dc5de35] cherry picked
1 file changed, 1 insertion(+), 1 deletion(-)
• (M) $ git cherry M Z
+ 153c2f840f2192382be1fc435ceb069f0814d7ff
+ 4a7979d5dd526245b51769db21acf4c286825036
Run Code Online (Sandbox Code Playgroud)
因此,在我做出改变之后,它仍然认为这两项变化都不是我所期待的:
- 153c2f840f2192382be1fc435ceb069f0814d7ff
+ 4a7979d5dd526245b51769db21acf4c286825036
Run Code Online (Sandbox Code Playgroud)
从现在起我怎么会知道我已经合并了153c2f?我怎样才能以一种了解合并的方式进行挑选?
你怎么知道?
不是通过使用git cherry,因为它只识别具有相同内容的提交git patch-id(请参阅手册页),即不是那些您必须解决重要冲突的提交。
所以你必须通过查看提交消息来知道。
未来的合并将如何了解樱桃选择?
由于您在应用精选更改时已经解决了冲突,因此当您将来合并整个分支时,该提交应该会简单地合并。
如果你真的担心 git 记住你如何解决冲突,你可以启用git rerere:
git config --global rerere.enabled true
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10822 次 |
| 最近记录: |