gerrit/Documentation/concept-refs-for-namespace.txt
David Shevitz d87d84141a Add new concept topic on refs/for namespace
This topic is intended to provide more conceptual/in-depth information
for users. By adding this topic, we have something we can link to in
future how-to and tutorial topics, so we don't have to re-explain
what the refs/for namespace is each time.

This content for this topic originated from several other existing
topics. Those topics are still in place in the documentation. This
duplication is expected, until such a time as the Concepts section
is more complete.

Change-Id: I91cf6da1bdc1f8f53031ab2c0ac2a4c08fb4c0ff
2017-08-09 19:02:17 -07:00

73 lines
1.8 KiB
Plaintext

= The refs/for namespace
When pushing a new or updated commit to Gerrit, you push that commit using a
link:https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html#def_ref[reference],
in the `refs/for` namespace. This reference must also define
the target branch, such as `refs/for/[BRANCH_NAME]`.
For example, to create a new change on the master branch, you would use the
following command:
....
git push origin HEAD:refs/for/master
....
The `refs/for/[BRANCH_NAME]` syntax allows Gerrit to differentiate between
commits that are pushed for review and commits that are pushed directly into
the repository.
Gerrit supports using either the full name or the short name for a branch. For
instance, this command:
....
git commit
git push origin HEAD:refs/for/master
....
is the same as:
....
git commit
git push origin HEAD:refs/for/refs/heads/master
....
Gerrit uses the `refs/for/` prefix to map the concept of "Pushing for Review" to
the git protocol. For the git client, it looks like every push goes to the same
branch, such as `refs/for/master`. In fact, for each commit pushed to this ref,
Gerrit creates a new ref under a `refs/changes/` namespace, which Gerrit uses
to track these commits. These references use the following format:
....
refs/changes/[CD]/[ABCD]/[EF]
....
Where:
* [CD] is the last two digits of the change number
* [ABCD] is the change number
* [EF] is the patch set number
For example:
....
refs/changes/20/884120/1
....
You can use the change reference to fetch its corresponding commit:
....
git fetch https://[GERRIT_SERVER_URL]/[PROJECT] refs/changes/[XX]/[YYYY]/[ZZ] \
&& git checkout FETCH_HEAD
....
NOTE: The fetch command can be copied from the
link:user-review-ui.html#download[download command] in the Change screen.
GERRIT
------
Part of link:index.html[Gerrit Code Review]
SEARCHBOX
---------