[Git] 关于refs/for/ 和refs/heads/

简介:

转载自: 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".

 

关于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.

分类:  Git
本文转自demoblog博客园博客,原文链接http://www.cnblogs.com/0616--ataozhijia/p/4165052.html如需转载请自行联系原作者

demoblog
相关文章
|
7月前
|
开发工具 git
Git -- 代码上传错误 error: failed to push some refs to ‘git@gitee.com:JMFive/uni-shop2.git‘
Git -- 代码上传错误 error: failed to push some refs to ‘git@gitee.com:JMFive/uni-shop2.git‘
|
开发工具 git
git报错error: failed to push some refs to ‘https://gitee.com/XXX/XXX-mater.git‘
git报错error: failed to push some refs to ‘https://gitee.com/XXX/XXX-mater.git‘
git报错error: failed to push some refs to ‘https://gitee.com/XXX/XXX-mater.git‘
|
7月前
|
网络安全 开发工具 git
git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决
git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决
87 0
|
6月前
|
开发工具 git
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
|
6月前
|
开发工具 git
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
737 1
|
6月前
|
开发工具 git
MAC如何使用Git命令行上传本地项目及理解,failed to push some refs to ‘https://gitee.com/brother-barking/spxx.git
MAC如何使用Git命令行上传本地项目及理解,failed to push some refs to ‘https://gitee.com/brother-barking/spxx.git
|
7月前
|
Shell 开发工具 数据安全/隐私保护
git上传项目一直报一个文件没有添加任何内容(git上拉去别人的项目上传到自己的仓库/error: failed to push some refs to ‘https://gitee.com/)
git上传项目一直报一个文件没有添加任何内容(git上拉去别人的项目上传到自己的仓库/error: failed to push some refs to ‘https://gitee.com/)
324 0
git上传项目一直报一个文件没有添加任何内容(git上拉去别人的项目上传到自己的仓库/error: failed to push some refs to ‘https://gitee.com/)
|
7月前
|
开发工具 git
[Git Error] failed to push some refs to “××××.git”
[Git Error] failed to push some refs to “××××.git”
104 0
|
Shell BI 开发工具
【问题解决】Git报错:failed to push some refs to xxxxx
Git报错:failed to push some refs to xxxxx
506 0
|
Linux Shell 网络安全
git上传文件到Gitee报错“error: failed to push some refs to https://gitee.com/xxxx”
我要将一个 4.27 GB 的文件上传到 Gitee 上,但是出现了下面这样的报错 error: failed to push some refs to 'https://gitee.com/xxxx/centos.git 因此记录一下解决报错的方法。
1032 2