git推送代码问题之:ERROR: [abcdefg] missing Change-Id in commit message footer
一、问题:
在日常的工作中,使用git推送代码时会出现以下报错,“missing Change-Id in commit message” :
qinjiaxi:$ git push origin HEAD:refs/for/develop
对象计数中: , 完成.
Delta compression using up to threads.
压缩对象中: % (/), 完成.
写入对象中: % (/), 10.92 KiB | bytes/s, 完成.
Total (delta ), reused (delta )
remote: Resolving deltas: % (/)
remote: Processing changes: refs: , done
remote: ERROR: [abcdefg] missing Change-Id in commit message footer
remote:
remote: Hint: To automatically insert Change-Id, install the hook:
remote: gitdir=$(git rev-parse --git-dir); scp -p -P xxx.com.cn:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote: git commit --amend
remote:
To ssh://xxx.com.cn:29418/ZXXXX-XXXX-XXXX
! [remote rejected] HEAD -> refs/for/develop ([abcdefg] missing Change-Id in commit message footer)
二、问题分析:
从上述错误信息中可以看出来,该提交缺少Change-ID。由于Change-ID对于git仓库来讲是该提交唯一可识别的ID,因此,缺少Change-ID是一个Fatal error,这样肯定是不能入库的。一般情况下,Change-ID都是由".git/hooks/commit-msg"脚本在执行"git commit"的时候自动生成的。如果出现上述错误,极有可能是当前git库下缺少上述".git/hooks/commit-msg"脚本。(可能是克隆的时候没有选择Clone with commit-msg hook)

三、解决方案
3.1获取commit-msg脚本
使用提示中的命令获取commit-msg脚本:
gitdir=$(git rev-parse --git-dir); scp -p -P xxx.com.cn:hooks/commit-msg ${gitdir}/hooks/
注:会弹出一个页面,这里直接按照页面的提示退出就行
3.2追加提交:
git commit --amend
3.3推送到代码库:
git push origin HEAD:refs/for/develop
通常以上的几部能够解决问题,如果不能解决的话还可以用以下的方法
由于有多个commit这里我们需要merge合并这些commit为一个然后提交。(前提条件:使用git pull命令拉取最新代码)
1、首先我们创建一个分支
git branch develop_merge
2、然后我们切换到1中创建的分支并删除develop分支
git checkout develop_merge
git branch -D develop
3、切换到develop分支
git checkout develop
4、git三连
git merge --squash develop_merge
git add .
git commit -m "描述"
其中--squash命令的作用是将develop_merge分支上的几次commit"压缩"后合并到develop分支。
5、最后我们推送代码到远端仓库
git push origin HEAD:refs/for/develop
git推送代码问题之:ERROR: [abcdefg] missing Change-Id in commit message footer的更多相关文章
- 使用git推送代码到开源中国以及IDEA环境下使用git
使用git推送代码到开源中国以及IDEA环境下使用git 在学习Java的过程中我们会使用到git这个工具来将我们本周所编写的代码上传到开源中国进行代码托管,而在使用git的时候有很多的同学由于不会操 ...
- Git—推送代码至Github
Git—上传代码至Github 首先得有个Github的账户,然后创建一个库. 然后找到指向改库的URL 第一次上传需要设置用户邮箱,打开git安装文件/bin下面找到git.bash并打开,设置全局 ...
- git推送代码Gogs报401错误
1.git push 报错:RPC failed; HTTP 401 curl 22 The requested URL returned error: 401 The remote end hung ...
- git推送代码报错:fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream
情景再现 远程新建仓库,然后本地 git bash执行以下代码 git init git add . git commit -m 'xxx' git remote add origin https:/ ...
- git 推送代码到远程端
git init git add . git commit -m "first commit" git remote add origin "地址" git p ...
- 使用nginx代理gogs遇到推送代码错误的问题(RPC failed; HTTP 413 curl 22 The requested URL returned error: 413)
前提 代码管理我是用Gogs.Git,前些阵子使用Nginx将git.balabiu.com反向代理到了Gogs的默认端口,其他二级域名准备做其他使用, 导致上报代码出现了错误. 问题 推送代码报错误 ...
- git 打tag(版本)、推送代码
服务端:192.168.0.96 gitlab 客户端:192.168.0.97 git 服务端gitlab安装请参照: https://www.cnblogs.com/effortsing/p/10 ...
- git推送本地分支到远端 以及删除远端分支的 命令
git推送本地分支到远端 当前处于master分支,尝试用了git push origin warning: push.default is unset; its implicit value is ...
- 关于windows下的虚拟机Homestead在推送代码上github 步骤
1.ssh 秘钥登录配置 使用以下命令检查主机是否生成SSH Key: > ls -al ~/.ssh 2.如果有秘钥,那就跳过这个步骤,如果没有秘钥,则运行以下命令来生成秘钥: ssh-key ...
随机推荐
- 关于VUE的路由地址问题
目前我们VUE的项目都是单页面应用,路由地址全都是#以不同的锚点去分发,根目录就是 http://localhost:8080/index#/ (至于为什么不是http://localhost:8 ...
- tp5中的input助手函数
详见手册:https://www.kancloud.cn/manual/thinkphp5/118044
- Python学习17之类3继承
'''''''''继承:在继承原有类功能的基础上,增加新的功能(属性或者方法),形成新的类被继承的类:父类新的类:子类 格式:class 子类(父类) class 子类(父类1,父类2,父类3...) ...
- Cannot find libcrypto in Ubuntu
https://stackoverflow.com/questions/13811889/cannot-find-libcrypto-in-ubuntu sudo apt-get install li ...
- Mybatis 使用 SQL 递归获取单表中的树结构
xml 代码 <resultMap type="xxx.xxx.xxx.xxx.实体类" id="xxxListTree"> <result ...
- 无法打开到SQL Server的连接 (Microsoft SQL Server, 错误:53) .
标题: 连接到服务器 ------------------------------ 无法连接到 MSSQLSERVER. ------------------------------ 其他信息: 在与 ...
- 如何在 Amazon AWS 上设置一台 Linux 服务器
摘要: AWS(Amazon Web Services)是全球领先的云服务器提供商之一.你可以使用 AWS 平台在一分钟内设置完服务器.在 AWS 上,你可以微调服务器的许多技术细节,如 CPU 数量 ...
- 在服务器本地监控服务端口命令之ss
在服务器本地监控服务端口命令之ss 当服务器的socket连接数量变得非常大时,无论是使用netstat命令还是直接cat /proc/net/tcp,执行速度都会很慢.可能你不会有 切身的感受,但当 ...
- Codeforce 140C (贪心+优先队列)补题
C. New Year Snowmen time limit per test2 seconds memory limit per test256 megabytes inputstandard in ...
- POJ Building a Space Station 最小生成树
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 15664 Accepted: 6865 Description You ...