blob: c8776ae1ae055037e77cfe1174f27b89a6b9894f [file] [log] [blame]
David Shevitzd87d8412017-08-04 08:20:27 -07001= The refs/for namespace
2
3When pushing a new or updated commit to Gerrit, you push that commit using a
4link:https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html#def_ref[reference],
5in the `refs/for` namespace. This reference must also define
6the target branch, such as `refs/for/[BRANCH_NAME]`.
7
8For example, to create a new change on the master branch, you would use the
9following command:
10
11....
12git push origin HEAD:refs/for/master
13....
14
15The `refs/for/[BRANCH_NAME]` syntax allows Gerrit to differentiate between
16commits that are pushed for review and commits that are pushed directly into
17the repository.
18
19Gerrit supports using either the full name or the short name for a branch. For
20instance, this command:
21
22....
23git commit
24git push origin HEAD:refs/for/master
25....
26
27is the same as:
28
29....
30git commit
31git push origin HEAD:refs/for/refs/heads/master
32....
33
34Gerrit uses the `refs/for/` prefix to map the concept of "Pushing for Review" to
35the git protocol. For the git client, it looks like every push goes to the same
36branch, such as `refs/for/master`. In fact, for each commit pushed to this ref,
37Gerrit creates a new ref under a `refs/changes/` namespace, which Gerrit uses
38to track these commits. These references use the following format:
39
40....
41refs/changes/[CD]/[ABCD]/[EF]
42....
43
44Where:
45
46* [CD] is the last two digits of the change number
47* [ABCD] is the change number
48* [EF] is the patch set number
49
50For example:
51
52....
53refs/changes/20/884120/1
54....
55
56You can use the change reference to fetch its corresponding commit:
57
58....
59git fetch https://[GERRIT_SERVER_URL]/[PROJECT] refs/changes/[XX]/[YYYY]/[ZZ] \
60&& git checkout FETCH_HEAD
61....
62
63NOTE: The fetch command can be copied from the
64link:user-review-ui.html#download[download command] in the Change screen.
65
66
67GERRIT
68------
69Part of link:index.html[Gerrit Code Review]
70
71SEARCHBOX
72---------