转载自: http://lishicongli.blog.163.com/blog/static/146825902013213439500/

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

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.

[Git] 关于refs/for/ 和refs/heads/的更多相关文章

  1. 关于refs/for/ 和refs/heads/

    1.     这个不是git的规则,而是gerrit的规则, 2.     Branches, remote-tracking branches, and tags等等都是对commite的引用(re ...

  2. git:hook declined FATAL: W refs/heads DENIED by fallthru error

    hook declined FATAL: W refs/heads DENIED by fallthru error git提交代码时报错,网上查了,最终结果竟然是测试人员没有给我配置写的权限,配置了 ...

  3. Git CMD - push: Update remote refs along with associated objects

    命令格式 git push [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pac ...

  4. git fail to push some refs....

    出现错误的主要原因是github中的README.md文件不在本地代码目录中 可以通过如下命令进行代码合并[注:pull=fetch+merge] git pull --rebase origin m ...

  5. git报错error: src refspec refs/heads/master does not match any.

    $ git pusherror: src refspec refs/heads/master does not match any.error: failed to push some refs 出错 ...

  6. Git远程分支和refs文件具体解释

    推送远程分支到同一个server 比方首先建立gitserver,顺便clone出两个副本 mkdir server cd server git init --bare cd .. git clone ...

  7. bad object refs/remotes/origin/HEAD

    How to handle git gc fatal: bad object refs/remotes/origin/HEAD error: failed to run repack I random ...

  8. react中的refs

    概述 很久之前就知道refs,感觉好神秘,恰好今天突然发现字符串形式的ref在官网不推荐使用了,于是好好总结一下ref的用法,供以后开发时参考,相信对其他人也有用. 参考资料: Refs & ...

  9. Refs & DOM

    Refs 提供了一种访问在 render 方法中创建的 DOM 节点或 React 元素的方式. 在典型的 React 数据流中, 属性(props)是父组件与子代交互的唯一方式.要修改子组件,你需要 ...

随机推荐

  1. [bzoj3098]Hash Killer 2——哈希

    题目 这天天气不错,hzhwcmhf神犇给VFleaKing出了一道题: 给你一个长度为N的字符串S,求有多少个不同的长度为L的子串. 子串的定义是S[l].S[l + 1].- S[r]这样连续的一 ...

  2. Pycharm中快捷键大全

    #1.按住ctrl然后鼠标放在函数上就会提示出这个函数有那些参数,双击进入该函数. 1.Pycharm中快捷键大全,遇到一个更新一个 撤销与反撤销:Ctrl + z,Ctrl + Shift + z ...

  3. 入园的第一篇--where、where

    这篇是入园的第一篇随便,后面我会将自己几年前写的博文都转到这里.哎,其实说到博文的事情,我就很郁闷,甚至有些恼火,后面我会详细说说这中间的过程,也许能帮助某些人避免遇到类似的事情.突然想起<西游 ...

  4. Linux内核中的GPIO系统之(3):pin controller driver代码分析--devm_kzalloc使用【转】

    转自:http://www.wowotech.net/linux_kenrel/pin-controller-driver.html 一.前言 对于一个嵌入式软件工程师,我们的软件模块经常和硬件打交道 ...

  5. Python/CMD 文件备份

    1.使用Python压缩文件并另存 import zipfile, os #备份文件ZIP格式: folder 目标文件夹 : Targetfolder:另存地址 def backuptozip(fo ...

  6. [ Openstack ] Openstack-Mitaka 高可用之 环境初始化

    目录 Openstack-Mitaka 高可用之 概述    Openstack-Mitaka 高可用之 环境初始化    Openstack-Mitaka 高可用之 Mariadb-Galera集群 ...

  7. 【LVS 】NAT方式实现过程

    LVS-NAT方式实现负载均衡 一.环境介绍

  8. Delphi2007新功能 -- 有限的栈对象

    今天使用Delphi2007,一个误输入,无意中发现Delphi2007的record类型居然能够和TObject一样定义方法和属性,而且不需要调用类似TObject.Create方法就能生成一个re ...

  9. QPS、TPS、PV等网站业务关键字释义

    QPS:Query Per Second TPS:Transaction Per Second PV:Page View RT:Response Time UV:Unique Visitor DAU: ...

  10. hadoop3.1伪分布式部署

    1.环境准备 系统版本:CentOS7.5 主机名:node01 hadoop3.1 的下载地址: http://mirror.bit.edu.cn/apache/hadoop/common/hado ...