gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 01:19:23 34 4
gpt4 key购买 nike

我刚开始使用 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/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com