git rebase 出现conflict怎么办

Rebase的执行顺序:
git rebase from_branch to_branch
从from_branch到目标分支to_branch进行rebase。结果是from_branch的代码更新到to_branch, 同时to_branch的commit log加到from_branch的最前方。

例子:
1. git rebase remotes/main/master MYBRANCH
从远程主fork的master分支到本地分支MYBRANCH进行rebase。
2. 如果出现conflict,如
 Using index info to reconstruct a base tree...  
 M     Keshin/keshin.xcodeproj/project.pbxproj  
 <stdin>:121: trailing whitespace.  
 <stdin>:173: trailing whitespace.  
 <stdin>:277: trailing whitespace.  
 <stdin>:329: trailing whitespace.  
 warning: 4 lines add whitespace errors.  
 Falling back to patching base and 3-way merge...  
 Auto-merging Keshin/keshin.xcodeproj/project.pbxproj  
 CONFLICT (content): Merge conflict in Keshin/keshin.xcodeproj/project.pbxproj  
 Failed to merge in the changes.  
 Patch failed at 0001 [KESHIN-381] Error Manager  
 The copy of the patch that failed is found in:  
   /Users/ou-h/Documents/Projects/src/git_src/fork_ou/katatema-ios-ou/.git/rebase-apply/patch  
 When you have resolved this problem, run "git rebase --continue".  
 If you prefer to skip this patch, run "git rebase --skip" instead.  
 To check out the original branch and stop rebasing, run "git rebase --abort".  
可见,当前是文件 Keshin/keshin.xcodeproj/project.pbxproj有conflict,
3. 解决冲突:
vim  Keshin/keshin.xcodeproj/project.pbxproj  
打开文件,修改并解决冲突。
4. git add  Keshin/keshin.xcodeproj/project.pbxproj
5. git rebase --continue
以上。

如果出现下面的问题:
`--> git rebase bug586-test master-test
First, rewinding head to replay your work on top of it...
Applying: - comiitting code related to api permissions
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
    inc/data.inc
    templates/apipermissions_tpl.inc
    templates/currencies_tpl.inc
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0001 - comiitting code related to api permissions

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".
解决:
I'm on a mac, and this obscure config change seemed to fix all my woes regarding unstaged changes when there were none.
git config --global core.trustctime false
I think it's to do with differences between windows file times, linux file times and mac file times. who knows, feel free to comment if you do.
以上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值