博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Git] 关于refs/for/ 和refs/heads/
阅读量:6229 次
发布时间:2019-06-21

本文共 2265 字,大约阅读时间需要 7 分钟。

转载自: 

1.     这个不是git的规则,而是gerrit的规则,

2.     Branches, remote-tracking branches, and tags等等都是对commite的引用(reference),引用都以 “refs/……”表示. 比如remote branch: origin/git_int(=refs/remotes/origin/git_int), local tag: v2.0(=refs/tags/v2.0), local branch: git_int(=refs/heads/git_int)…

3.     简单点说,就是refs/for/mybranch需要经过code review之后才可以提交;refs/heads/mybranch不需要code review

 

(since you want to directly push into the branch, rather than create code reviews. Pushing to refs/for/* creates code reviews which must be approved and then submitted. Pushing to refs/heads/* bypasses review entirely, and just enters the commits directly into the branch. The latter does not check committer identity, making it appropriate for importing past project history

如果需要code review,直接push

$git push origin master

那么就会有“! [remote rejected] master -> master (prohibited by Gerrit)的错误信息

而这样push就没有问题,

$git push origin HEAD:refs/for/mybranch

 

下面一段是对“refs/for”更详细的描述:

 

The documentation for Gerrit explains that you push to the "magical refs/for/'branch' ref using any Git client tool".

 

关于refs/for/ - Lishic - Theres always a way

 

This 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 it's 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.  

 

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.

你可能感兴趣的文章
java-第十一章-类的无参方法-实现菜单的级联效果
查看>>
如何检测集群中每台主机的状态
查看>>
时针、分针在一昼夜 24 小时内重合多少次?
查看>>
PHP 5 常量
查看>>
第44讲:Scala中View Bounds代码实战及其在Spark中的应用源码解析
查看>>
react的style里面不支持important的解决办法
查看>>
JS基本问题
查看>>
我的第一篇博客
查看>>
php版本之殇
查看>>
IDEA 葵花宝典
查看>>
IDEA 问题汇总
查看>>
vmware安装软件包时出错 windows installer返回1613
查看>>
XenDesktop5.x/XenApp6.x访问数据流
查看>>
python 的日志logging模块学习
查看>>
HBase 源码编译错误: RpcServer.java: cannot find symbol
查看>>
zabbix监控中遇到的错误
查看>>
Centos7.5-文件权限管理
查看>>
Linux下安装wordpress和phpMyadmin,并为phpMyadmin添加ssl
查看>>
VM中文字界面linux调整分辨率
查看>>
tomcat虚拟主机 server.xml文件配置
查看>>