解决merge时代码冲突 "Please rebase your change and upload a new patchset"

声明:

本博客欢迎转发,但请保留原作者信息!

博客地址:http://blog.csdn.net/llg8212

内容系本人学习、研究和总结,如有雷同,不胜荣幸!


当代码core view后,就会被合到主干代码。由于很多人同时在修改代码,所以merge时可能会存在代码冲突的情况。当出现如下信息时,就说明你的代码和主干代码有冲突了。

Doesn't seem to work

Build failed. For information on how to proceed, seehttps://wiki.openstack.org/wiki/GerritJenkinsGit#Test_Failures

This change was unable to be automatically merged with the currentstate of the repository. Please rebase your change and upload a newpatchset.


解决办法

git checkout master
git fetch --all                     # Fetch all remotes
git reset --hard origin/master     # Resets the index and working
tree. Any changes to tracked files
 in the working tree since <commit> are discarded。
git review -d <patchNumber>        # patchNumber为提patch时生成的数字串,

在代码review中。如: https://review.openstack.org/#/c/64127/1
git rebase master                  # If <branch> is specified, git
rebase will perform an automatic git
 checkout <branch> before doing anything else. Otherwise it remains on
 the current branch.

这时就将主干的代码合入到本地了,通过git status就能看到修改的内容和冲突的文件。如:

# Not currently on any branch.
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: glance/api/v2/image_data.py
# modified: glance/api/v2/image_members.py
# modified: glance/api/v2/image_tags.py
# modified: glance/api/v2/images.py
# modified: glance/store/gridfs.py
# modified: glance/store/rbd.py
#

# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: glance/store/cinder.py
#


解决完冲突后,测试用例运行正常,再提交代码。

$ git add       注:必须使用git add命令,而不能使用git commit -a来提交
$ git rebase --continue
注:使用git rebase --continue后,用git status查看有时会发现当前不在任何分支上,这时需要再执行一次 git rebase --continue。
$ git review -R
但是比较郁闷的是,两个core review就泡汤了。但如果用例正常通过,很快能再被core review。


注:使用git review -d <patchNumber>可以直接从review下载review的代码到本地。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值