Git 与 Gerrit 应用1

Git 与 Gerrit 应用1—>遇到 Conflict

使用git总有一天会遇到Conflict,所以简单讲一下解决办法

1.如果在 git push 之出现类似下列信息,表示有 conflict 发生:

! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘http://ryan.chang@172.18.51.25:8082/Sandbox
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.
2.Hint 里包含了不少信息,总之就是有其他人先commit了,但现在gerrit设定只收‘fast-forwad’的commit,所以先把其他人改的版本抓下來:

$ git fetch
3.接下来要想办法修改 local repository 的历史,好让 gerrit server 愿意收 commit … 用 git rebase

4.其实通常来说 git 会很聪明的做完调整,所以如果在 git rebase 之后沒有看到什麼可怕的信息,应该就可以回到 git push 的路线,再次把 commit 推上去了。但这里还是讲一下真的 conflict 的状况,你应该会看到类似下面的信息:

$ git rebase
First, rewinding head to replay your work on top of it…
Applying: Hello again!
Using index info to reconstruct a base tree…
M foo
Falling back to patching base and 3-way merge…
Auto-merging foo
CONFLICT (content): Merge conflict in foo
Failed to merge in the changes.
Patch failed at 0001 Hello again!
The copy of the patch that failed is found in:
…/Sandbox/.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”.
5.那么来merge 吧,敲 git mergetool,[Enter],

6.改成你最后希望的样子之后,存档,离开编辑器,告诉 git 可以继续 rebase 了:

$ git rebase –continue
Applying: Hello again!
7.rebase 完成后,就可以回到 git push 路线去了

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值