GIT 5 冲突解决2

使用git pull,修改conflic文件后add,在push的方法虽然简单,但是从库上可以看到一条冗余的merge信息,通过git rebase则可以避免这条冗余信息的显示。

假设本地修改完成后,开始入库,因为别人也做了修改已经入库,所以push时会返回错误信息:

[smbtest@localhost a]$ git push origin master

 ! [rejected]        master -> master (non-fast-forward)

这时可以将远端origin的信息checkout到本地,然后使用rebase命令使master分支先暂存本地的修改,与origin同步,然后将本地修改重新加回到master

[smbtest@localhost a]$ git fetch origin
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ssh://sny-jira.ads.finisar.com:7999/gpon/test
   1e65431..e9a3565  master     -> origin/master
[smbtest@localhost a]$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: add 8a
Using index info to reconstruct a base tree...
M       b.txt
Falling back to patching base and 3-way merge...
Auto-merging b.txt
CONFLICT (content): Merge conflict in b.txt
Failed to merge in the changes.
Patch failed at 0001 add 8a

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

[smbtest@localhost a]$ vi b.txt
[smbtest@localhost a]$ git add b.txt
[smbtest@localhost a]$ git rebase --continue
Applying: add 8a
[smbtest@localhost a]$ git push origin master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 301 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh://git@sny-jira.ads.finisar.com:7999/gpon/test.git
   e9a3565..5bcc4db  master -> master
[smbtest@localhost a]$

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值