git把一个分支的commit merge到另外一个分支

例如要将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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值