關於refs/for/

1.     這個不是git的規則,而是gerrit的規則, git

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)… app

3.     簡單點說,就是refs/for/mybranch須要通過code review以後才能夠提交;refs/heads/mybranch不須要code review ide

 

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 spa

若是須要code review,直接push code

$git push origin master orm

那麼就會有! [remote rejected] master -> master (prohibited by Gerrit)的錯誤信息 rem

而這樣push就沒有問題, it

$git push origin HEAD:refs/for/mybranch io

 

下面一段是對「refs/for」更詳細的描述: ast

 

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.

相關文章
相關標籤/搜索