$ git log --pretty=oneline
4bf41302efc10dd4a6e85c35ec8ef02b1b32e633 (HEAD -> master) second
1e2196ba347c4338bfa7589aabe2513ecabeeedd first
readme内容:
1
2
11111111111
22222222222222
dev的提交历史如下:
1
2
3
4
5
6
$ git log --pretty=oneline
16ae2df968afd92b89f97171480d764ec607deaf (HEAD -> dev) dev 5566
a25a08a678d55f7fa60c4185c2db38258aa9a700 dev 44444
9dc6d54e0357bfde4ccdc0b81888079d4fd4f585 dev 333
4bf41302efc10dd4a6e85c35ec8ef02b1b32e633 (master) second
1e2196ba347c4338bfa7589aabe2513ecabeeedd first
readme内容:
1
2
3
4
5
6
11111111111
22222222222222
dev 3333333333333
dev 44444444444444
dev 55555555555555555
dev 6666666666666666666
下面,我要把dev分支的16ae2df9合并到master中。
1
2
git checkout master
git cherry-pick 16ae2df9
如果出现冲突:
1
2
3
4
$ git cherry-pick a25a08...16ae2df9
error: a cherry-pick or revert is already in progress
hint: try "git cherry-pick (--continue | --quit | --abort)"
fatal: cherry-pick failed
$ git cherry-pick 16ae2df9
error: could not apply 16ae2df... dev 5566
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'
解决办法是先使用status命令看看什么文件冲突了:
1
2
3
4
5
6
7
8
9
10
11
12
$ git status
On branch master
You are currently cherry-picking commit a25a08a.
(fix conflicts and run "git cherry-pick --continue")
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
打开readme文件看看:
1
2
3
4
5
6
7
8
9
11111111111
22222222222222
<<<<<<< HEAD
=======
dev 3333333333333
dev 44444444444444
dev 55555555555555555
dev 6666666666666666666
>>>>>>> 16ae2df... dev 5566