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