例如要将A分支的一个commit合并到B分支:
首先切换到A分支
git checkout A
git log
找出要合并的commit ID :
例如
0128660c08e325d410cb845616af355c0c19c6fe
然后切换到B分支上
git checkout B
git cherry-pick 0128660c08e325d410cb845616af355c0c19c6fe
然后就将A分支的某个commit合并到了B分支了
最后执行git push
git cherry-check error “fatal: bad object”
**- git checkout branch-a
- git pull origin branch-a
- git checkout branch-b
- git pull origin branch-b
- git cherry-pick
(branch-a 另一个branch. branch-b本地)**
如果在cherry-pick 的过程中出现了冲突
Automatic cherry-pick failed. After resolving the conflicts,
mark the corrected paths with 'git add ’ or 'git rm ’
and commit the result with:
git commit -c 15a2b6c61927e5aed6718de89ad9dafba939a90b
就跟普通的冲突一样,手工解决:
2.1 $ git status # 看哪些文件出现冲突
both modified: app/models/user.rb
2.2 $ vim app/models/user.rb # 手动解决它。
2.3 $ git add app/models/user.rb
2.4 git commit -c <新的commit号码>
hint: after resolving the conflicts, mark the corrected paths
解决方式
This means that you need to explicitly tell Git that you’ve resolved a conflict at each file or folder (that is path).
Showing the list of yet unresolved conflicts:
git status
Marking a conflict as resolved.
File or all files in a folder should be left and all conflicts are resolved:
git add
File or folder should be removed:
git rm
Next step:
git commit