gerrit上提示代码冲突的时候,我们首先会想到rebase下,不行的话就只能解决冲突了,最简单的做法是我的另一篇博客https://www.cnblogs.com/zndxall/p/9140813.html 中的方法,但是有的时候还是会出现问题,报错commit xxxx is a merge but no -m option was given,如下:

或者执行git cherry-pick 4e73b64a5fc251e6ff82aa1db4316bd4ecd389d5 是一样的效果。

出现这个问题,是因为提交的代码之前pull 了其他人的代码并合入了自己本地的代码,产生了一个merge操作以后,又push到代码仓,就会出现这种情况,我们看下他的提交日志:

分3个点解释,标记“1”很明显是一个merge操作,标记“2”是他自己的改动,标记“3”我们看到parent节点有两个,一个merge里有多个父节点,cherry-pick的时候至少要指定一个父节点,可以用-m parent-num来指定,parent-num 默认从1开始,比如上面的两个父节点,

上面一个父节点29b3eb321d8f512616fad12ce40d7ed22d5d4371的parent-num 为1  ,

下面一个父节点43bd1d238829f067547ebd8f372a6ded5732690a的parent-num为2,

那么在cherry-pick的时候,如果选定父节点为第一个的话,

命令为 git cherry-pick 4e73b64a5fc251e6ff82aa1db4316bd4ecd389d5 -m 1

结果如下:

(备注:如果这里显示失败的话,如果没有失败的话,不用关心这一步,如图:

是因为你cherry-pick了两次,所以需要取消上次的cherry-pick操作,有多种方式,一种是回退到比较老的节点,然后pull最新代码,一种是基于目标分支重新建一个分支专门用来做cherry-pick)

接着再执行git status ,会提示冲突文件,如下:

修改冲突文件后,执行git add . (即add 所有修改),然后git commit -s 写评论,然后git push origin HEAD:refs/for/$branch提交入库即可 ($branch为你的当前工作分支)。

git cherry-pick 报错is a merge but no -m option was given的更多相关文章

  1. 记Git报错-refusing to merge unrelated histories

    记Git报错-refusing to merge unrelated histories   系统:win7 git版本: 2.16.2.windows.1 问题 1.本地初始化了git仓库,放了一些 ...

  2. 在使用 Git pull 时候报错 error: inflate

    在使用 Git pull 时候报错 error: inflate 具体的错误是 这样的 error: inflate: data stream error (unknown compression m ...

  3. AS添加依赖报错Unable to merge dex

    AS添加依赖报错Unable to merge dex 最近在给项目添加依赖的时候,要给项目导入Bmob的SDK,参照Bmob的官方文档,可以直接在app的build.gradle文件中添加 //Bm ...

  4. git同步遇到报错

    git同步遇到报错 “fatal: unable to access ‘https://github.com/ruanwenwu/newp.git/‘: Peer reports incompatib ...

  5. git https 请求报错 504

    git https 请求报错 504 原因可能是因为设置了代理,ubuntu/deepin 系统可以检查 /etc/profile ~/.bashrc 内有没有设置 https 的代理. 有的话,去掉 ...

  6. git切换分支报错:error: pathspec 'origin/XXX' did not match any file(s) known to git

    项目上有一个分支test,使用git branch -a看不到该远程分支,直接使用命令git checkout test报错如下: error: pathspec 'origin/test' did ...

  7. git同步遇到报错“fatal: unable to access 'https://github.com/lizhong24/mysite2.git/': Peer reports incompatible or unsupported protocol version.”

    git同步遇到报错“fatal: unable to access 'https://github.com/lizhong24/mysite2.git/': Peer reports incompat ...

  8. git提交代码报错 trailing whitespace的解决方法

    1. git提交代码报错 trailing whitespace 禁止执行pre-commit脚本 进入到项目目录中 chmod a-x .git/hooks/pre-commit 2.git提交代码 ...

  9. kafka 创建消费者报错 consumer zookeeper is not a recognized option

    在做kafka测试的时候,使用命令bin/kafka-console-consumer.sh --zookeeper 192.168.0.140:2181,192.168.0.141:2181 --t ...

随机推荐

  1. E - 487--3279

    Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is ...

  2. STL之map学习实例

    ``` #include<iostream> #include<algorithm> #include<vector> #include<map> #i ...

  3. 设计模式学习--Prototype

    What Prototype:用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. Why Prototype适用于在一个类的实例有几种不同的状态组合的一种时,建立相应的数目的原型并克隆她 ...

  4. 笔记本串口连接IBM 小机

    首先要有一根两头母的九针串口线&USB转串口线其次,配置波特率19200.数据位8.停止位1.无校验位.流控:Xon/Xoff P4是9600,P5 P6都是19200了( 默认是19200波 ...

  5. LeetCode 29 - 两数相除 - [位运算]

    题目链接:https://leetcode-cn.com/problems/divide-two-integers/description/ 给定两个整数,被除数 dividend 和除数 divis ...

  6. AngularJS 常用的功能

    第一 迭代输出之ng-repeat标签ng-repeat让table ul ol等标签和js里的数组完美结合 例: <ul><li ng-repeat="person in ...

  7. mail 发送email

    (一)首先安装ssmpt和mailutils: sudo apt-get install ssmtp mailutils (二)接下来编辑配置文件sudo gedit /etc/ssmtp/ssmtp ...

  8. Python开发【笔记】:抓包(实时分隔)

    抓包 进行linux系统抓包,并且定时分隔防止文件太大 #!/usr/bin/env python # -*- coding:utf-8 -*- import os import sys import ...

  9. vue项目使用vue-photo-preview插件实现点击图片放大预览和移动

    官方链接: http://npm.taobao.org/package/vue-photo-preview # 安装 npm install vue-photo-preview --save # 引入 ...

  10. linux批量替换文本字符串

    (一)通过vi编辑器来替换.vi/vim 中可以使用 :s 命令来替换字符串.:s/well/good/ 替换当前行第一个 well 为 good:s/well/good/g 替换当前行所有 well ...