git cherry-pick 报错 fatal: bad object

  场景:程序员A提交了一个commit到gerrit上,我们叫他为commit_id1,但是还没有review,那就是没有入库,程序员B想再本地拿到这个commitd_id1,既然这个提交没有入库,很明显,B单纯执行git pull是拿不到这个提交的,那他要怎么办呢,

  目前我想到的有几种方式:第一种如果只是单纯了改了很少量的文件,我们不排斥程序员A把这几个文件直接发给B。如果改动比较大呢?第二种,程序员A本地关于这个提交生成一个patch,发给B,B再在本地把这个patch打上,这是个不错的方式。还有一种,完全不需要额外的动作,只要使用git cherry-pick就可以了。

  所以,本篇的关注点是最后一种git cherry-pick的方式,如果想要使用patch的方式,参考我的另一篇博客:https://www.cnblogs.com/zndxall/p/8093455.html

  然后B在本地执行了git cherry-pick commit_id1,接着报错 fatal: bad object  commit_id1了!!! 那是因为git cherry-pick是本地特性,本地要有这个commit才可以被git cherry-pick。但是他本地并没有这个commit id,所以出现了这个错

既然用了gerrit,那么就用gerrit提供的cherry-pick就好了,如下:

(1)登陆gerrit页面,找到A提交的commit_id1,点击右上角的‘download’,然后复制cherry-pick那条,如下:

(2)然后再本地执行刚才复制的命令,执行,如下:

如果跟B本地的文件有冲突,会显示error,然后执行git status 可以看到‘both modify’的字样,告诉你了冲突文件,修改冲突文件即可。

如果没有冲突,命令执行完,B本地执行git log 就可以看到A的commit_id1的提交了。

原文地址:https://www.cnblogs.com/zndxall/p/9641586.html

时间: 2024-07-30 13:37:02

git cherry-pick 报错 fatal: bad object的相关文章

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

git同步遇到报错"fatal: unable to access 'https://github.com/ruanwenwu/newp.git/': Peer reports incompatible or unsupported protocol version." 网上很多人说是因为git版本需要升级.我将git版本升级到最新, [[email protected] tp5test]# git --version git version 2.16.2 问题却依然存在. 最后: y

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 incompatible or unsupported protocol version." 解决办法: yum update -y nss curl libcurl 问题解决了. git同步遇到报错"fatal: unable to access 'https://github.com/liz

新目录下使用git管理,未配置.git目录,报错fatal: Not a git repository (or any of the parent directories): .git

fatal: Not a git repository (or any of the parent directories): .git 第一次用Git,遇到这个错误提示,原来是这样的: fatal: Not a git repository (or any of the parent directories): .git This tells you that the directory you're in is not a git repository. Before you can add

GitHub Desktop报错fatal: unable to access 'https://github.com……: schannel: failed to open CA file 'C:/Users……bundle.crt': No such file or directory的解决办法

昨天github桌面版push的时候开始报错,提示某个crt文件找不到,大概就是下面这样 fatal: unable to access 'https://github.com/XXX/': schannel: failed to open CA file 'C:/Users/Andrew/AppData/Local/GitHubDesktop/app-1.2.2/resources/app/git/mingw64/bin/curl-ca-bundle.crt': No such file or

selenium调用Firefox和Chrome需要注意的一些问题,和出现的报错selenium:expected [object undefined] undefined to be a string

在高版本selenium下如:selenium3.4.3 1.高版本的selenium需要浏览器安装一些补丁驱动 Firefox:geckodriver 下载网址:http://download.csdn.net/detail/ztzy520/9725887 或https://github.com/mozilla/geckodriver/release 如:geckodriver-v0.14.0-win32 Chrome:chromedriver 下载网址:http://chromedriver

python框架Scrapy报错TypeError: 'float' object is not iterable解决

原因是:Twisted版本高了. 解决办法: 只要把Twisted库降级到16.6.0即可: 1 pip3 install Twisted==16.6.0 2 3 注:Twisted16.6.0安装后,会自动卸载高版本的Twisted python框架Scrapy报错TypeError: 'float' object is not iterable解决

pip运行报错Fatal error in launcher: Unable to create process using pip.exe

使用pip的时候报错Fatal error in launcher: Unable to create process using pip.exe 解决办法,升级pip python -m pip install -U pip 或者 python -m pip install --upgrade pip

Mysql报错Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

安装mysql后,启动时候没有启动成功,查看了下日志报错如下:--------------------------------------------- 1   可以:初始化mysql:mysql_install_db 2   目录权限问题chown -R mysql:mysql  /var/lib/mysql [[email protected] local]# less /var/log/mysqld.log1.查看报错信息如下:[ERROR] Fatal error: Can't open

故障案例:主从同步报错Fatal error: The slave I/O thread stops because master and slave have equal MySQL server

场景一:因为数据量非常,大概有1.4T,需要在原先master1-slave1的情况下再创建一个库slave2,并且挂在slave1下,即master1-slave1-slave2的结构.为了方便,当时停掉从库salve1,show master status记录状态,开启log_slave_updates,并且关闭salve1,然后将这个从库的data文件夹直接copy到新的从库,结果在创建slave2和slave1的主从关系时报错 Fatal error: The slave I/O thr