为什么git push gerrit HEAD:使用refs / for / master而不是git push origin master [英] Why is git push gerrit HEAD:refs/for/master used instead of git push origin master

查看:4852
本文介绍了为什么git push gerrit HEAD:使用refs / for / master而不是git push origin master的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



如果我做了 git push origin master 错误说! [remote rejected] master - > (Gerrit禁止)

解决方案

Gerrit的文档,特别是推送更改部分,解释说您推送到神奇的 refs / for /'branch' ref使用任何Git客户端工具。



以下图片来自 Gerrit简介。当你推送到Gerrit时,你需要执行 git push gerrit HEAD:refs / for /< BRANCH> 。这会将您的更改推送到临时区域(在图中为待定更改)。 Gerrit实际上并没有一个名为< BRANCH> 的分支;它位于git客户端。

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


当接收到推送请求以在其中一个名称空间中创建ref时,Gerrit执行自己的逻辑来更新数据库,然后向客户询问操作结果。一个成功的结果会导致客户相信Gerrit创建了ref,但实际上Gerrit并没有创建ref。 [链接 - Gerrit,坚韧细节]。



在一个成功的补丁(即补丁已经推送给Gerrit,[将其放入Pending Changes暂存区域中),审查和审查已经通过),Gerrit将Pending Changes中的更改推送到Authoritative Repository中,根据它推送到 refs / for /< BRANCH> 。通过这种方式,可以直接从 Authoritative Repository 的正确分支中提取成功审阅的修补程序。

I've just started using gerrit and I want to know why we need to do git push gerrit HEAD:refs/for/master instead of doing git push origin master

If I do git push origin master I get the error saying ! [remote rejected] master -> master (prohibited by Gerrit)

解决方案

The documentation for Gerrit, in particular the "Push changes" section, explains that you push to the "magical refs/for/'branch' ref using any Git client tool".

The following image is taken from the Intro to Gerrit. When you push to Gerrit, you do git push gerrit HEAD:refs/for/<BRANCH>. This pushes your changes to the staging area (in the diagram, "Pending Changes"). Gerrit doesn't actually have a branch called <BRANCH>; it lies to the git client.

Internally, Gerrit has its own implementation for the Git and SSH stacks. This allows it to provide the "magical" refs/for/<BRANCH> refs.

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"].

After a successful patch (i.e, the patch has been pushed to Gerrit, [putting it into the "Pending Changes" staging area], reviewed, and the review has passed), Gerrit pushes the change from the "Pending Changes" into the "Authoritative Repository", calculating which branch to push it into based on the magic it did when you pushed to refs/for/<BRANCH>. This way, successfully reviewed patches can be pulled directly from the correct branches of the Authoritative Repository.

这篇关于为什么git push gerrit HEAD:使用refs / for / master而不是git push origin master的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆