git - 为什么git push gerrit HEAD :refs/for/master used instead of git push origin master

标签 git gerrit

我刚开始使用 gerrit,我想知道为什么我们需要执行 git push gerrit HEAD:refs/for/master 而不是 git push origin master

如果我执行 git push origin master 我会收到错误信息 ! [远程拒绝] master -> master(Gerrit 禁止)

最佳答案

Gerrit 的文档,特别是 "Push changes"部分解释了您使用任何 Git 客户端工具推送到“神奇的 refs/for/'branch' ref”。

下图摘自the Intro to Gerrit .当你推送到 Gerrit 时,你会做 git push gerrit HEAD:refs/for/<BRANCH> .这会将您的更改推送到暂存区(在图中,“Pending Changes”)。 Gerrit 实际上并没有名为 <BRANCH> 的分支;它对 git 客户端说谎。

在内部,Gerrit 有自己的 Git 和 SSH 堆栈实现。这允许它提供“神奇的”refs/for/<BRANCH>引用。

When a push request is received to create a ref in one of these namespaces Gerrit performs its own logic to update the database, and then lies to the client about the result of the operation. A successful result causes the client to believe that Gerrit has created the ref, but in reality Gerrit hasn’t created the ref at all. [Link - Gerrit, "Gritty Details"].

The Gerrit workflow

补丁成功后(即补丁已经推送到Gerrit,[放入“Pending Changes”暂存区],审核通过,Gerrit从“Pending Changes”中推送变更进入“权威存储库”,根据推送到 refs/for/<BRANCH> 时它所做的魔法计算将其推送到哪个分支.这样,可以直接从 Authoritative Repository 的正确分支中提取成功审核的补丁。 .

关于git - 为什么git push gerrit HEAD :refs/for/master used instead of git push origin master,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10461214/

相关文章:

Github 更新/覆盖发布的现有 Assets

ubuntu - Gerrit 缺少所有项目

gerrit - 使用 REST API 查询 Gerrit?

python - 类型错误 : <built-in function id> is not JSON serializable

git - Jenkins 使用 git sparse checkout 触发

git - composer git clone --mirror 失败

h2 - 如何连接到Gerrit中使用的H2数据库

git - Jenkins 配置

git - 使用 git-svn 移动/重命名目录

git - TFVS 上的 TFS merge 冲突