Git Gerrit 使用时候的坑,自动创建合并请求

本文介绍了在使用Gerrit时遇到的提交权限问题及其解决方案。错误源于邮箱地址未正确设置以及git clone操作不完整。解决办法包括重新拉取仓库,完整执行代码,并确保commit到本地分支后再提交,Gerrit会自动创建合并请求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用Gerrit时候提交不成功,提示没有权限。

remote: ERROR: commit 00036e1: missing Change-Id in message footer
remote: Hint: to automatically insert a Change-Id,install the hook:
remote:	gitdir=$(git rev-parse --git-dir); scp -p -P 28110 username@127.0.0.1:hooks/commit-msg ${gitdir}/hooks/
remote: and then amend the commit:
remote:	git commit --amend --noedit
remote: Finally, push your changes again

其实原因

  • 没有设置正确的邮箱地址,邮箱地址必须跟gerrit上设置的一样
  • 其次在创建分支的时候,没有执行完整,而是直接复制git仓库地址git clone XXX。

之前一直使用GitLab,所以每次都是手动创建合并请求,而 Gerrit 可以通过这种方式自动创建合并请求

解决办法

1.重新拉去仓库到本地,执行完整的代码

git clone "ssh://username@127.0.0.1:2811/repo" && scp -p -P 2811 username@127.0.0.1:hooks/commit-msg "go-server/.git/hooks/"

2.递交的时候先commit到本地分支再

git commit -m "备注内容"
git push origin HEAD:refs/for/develop
git push origin HEAD:refs/for/v1.0.10

develop 是你要递交的分支,提交成功后,Gerrit 会默认在上面创建合并请求。

Enumerating objects: 19, done.
Counting objects: 100% (19/19), done.
Delta compression using up to 12 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (11/11), 7.44 KiB | 3.72 MiB/s, done.
Total 11 (delta 7), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (7/7)
remote: Processing changes: refs: 1, new: 1, done
remote:
remote: SUCCESS
remote:
remote:   http://127.0.0.1/c/repo/+/1671 提交的备注内容 [NEW]
remote:
To ssh://127.0.0.1:2811/repo
 * [new branch]      HEAD -> refs/for/dev
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值