blob: 9efbb21ff899f3a2f9dbc2d0691c43c87c09afd6 [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Uploading Changes
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -08002
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -07003Gerrit supports three methods of uploading changes:
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -08004
5* Use `repo upload`, to create changes for review
6* Use `git push`, to create changes for review
7* Use `git push`, and bypass code review
8
David Pursehousebaac4252013-01-25 17:42:19 +09009All three methods rely on authentication, which must first be configured
10by the uploading user.
11
12Gerrit supports two methods of authenticating the uploading user. SSH
13public key, and HTTP/HTTPS.
14
Edwin Kempin60ab8532013-03-27 14:33:46 +010015[[http]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080016== HTTP/HTTPS
David Pursehousebaac4252013-01-25 17:42:19 +090017
18On Gerrit installations that do not support SSH authentication, the
19user must authenticate via HTTP/HTTPS.
20
Han-Wen Nienhuys84d830b2017-02-15 16:36:04 +010021The user is authenticated using standard BasicAuth. Depending on the
22value of link:#auth.gitBasicAuthPolicy[auth.gitBasicAuthPolicy],
23credentials are validated using:
David Pursehousebaac4252013-01-25 17:42:19 +090024
Hector Oswaldo Caballero2a9ad1f2016-09-15 18:24:42 -040025* The randomly generated HTTP password on the `HTTP Password` tab
26 in the user settings page if `gitBasicAuthPolicy` is `HTTP`.
27* The LDAP password if `gitBasicAuthPolicy` is `LDAP`
28* Both, the HTTP and the LDAP passwords (in this order) if `gitBasicAuthPolicy`
29 is `HTTP_LDAP`.
30
Han-Wen Nienhuys84d830b2017-02-15 16:36:04 +010031When gitBasicAuthPolicy is not `LDAP`, the user's HTTP credentials can
32be regenerated by going to `Settings`, and then accessing the `HTTP
33Password` tab. Revocation can effectively be done by regenerating the
34password and then forgetting it.
David Pursehousebaac4252013-01-25 17:42:19 +090035
36For Gerrit installations where an link:config-gerrit.html#auth.httpPasswordUrl[HTTP password URL]
37is configured, the password can be obtained by clicking on `Obtain Password`
38and then following the site-specific instructions. On sites where this URL is
39not configured, the password can be obtained by clicking on `Generate Password`.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080040
Edwin Kempin1f556222015-04-22 13:24:39 +020041[[ssh]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080042== SSH
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080043
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070044Each user uploading changes to Gerrit must configure one or more SSH
45public keys. The per-user SSH key list can be accessed over the web
Edwin Kempinb5df3b82011-10-10 11:31:14 +020046within Gerrit by `Settings`, and then accessing the `SSH Public Keys`
47tab.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080048
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070049[[configure_ssh]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080050=== Configuration
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080051
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070052To register a new SSH key for use with Gerrit, paste the contents of
53your `id_rsa.pub` or `id_dsa.pub` file into the text box and click
54the add button. Gerrit only understands SSH version 2 public keys.
55Keys may be supplied in either the OpenSSH format (key starts with
56`ssh-rsa` or `ssh-dss`) or the RFC 4716 format (file starts with
57`---- BEGIN SSH2 PUBLIC KEY ----`).
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080058
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070059Typically SSH keys are stored in your home directory, under `~/.ssh`.
60If you don't have any keys yet, you can create a new one and protect
61it with a passphrase:
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080062
Michael Ochmannb99feab2016-07-06 14:10:22 +020063----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080064 ssh-keygen -t rsa
Michael Ochmannb99feab2016-07-06 14:10:22 +020065----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080066
67Then copy the content of the public key file onto your clipboard,
68and paste it into Gerrit's web interface:
69
Michael Ochmannb99feab2016-07-06 14:10:22 +020070----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080071 cat ~/.ssh/id_rsa.pub
Michael Ochmannb99feab2016-07-06 14:10:22 +020072----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080073
74[TIP]
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070075Users who frequently upload changes will also want to consider
David Pursehouse221d4f62012-06-08 17:38:08 +090076starting an `ssh-agent`, and adding their private key to the list
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070077managed by the agent, to reduce the frequency of entering the
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080078key's passphrase. Consult `man ssh-agent`, or your SSH client's
79documentation, for more details on configuration of the agent
80process and how to add the private key.
81
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070082[[test_ssh]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080083=== Testing Connections
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080084
85To verify your SSH key is working correctly, try using an SSH client
David Pursehouse221d4f62012-06-08 17:38:08 +090086to connect to Gerrit's SSHD port. By default Gerrit runs on
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080087port 29418, using the same hostname as the web server:
88
Michael Ochmannb99feab2016-07-06 14:10:22 +020089----
Hugo Arès93ef4272016-03-01 21:50:41 -050090 $ ssh -p 29418 sshusername@hostname
Edwin Kempinfb95a1b2011-10-05 10:08:00 +020091
92 **** Welcome to Gerrit Code Review ****
93
94 Hi John Doe, you have successfully connected over SSH.
95
96 Unfortunately, interactive shells are disabled.
97 To clone a hosted Git repository, use:
98
99 git clone ssh://sshusername@hostname:29418/REPOSITORY_NAME.git
100
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800101 Connection to hostname closed.
Michael Ochmannb99feab2016-07-06 14:10:22 +0200102----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800103
Edwin Kempinfb95a1b2011-10-05 10:08:00 +0200104In the command above, `sshusername` was configured as `Username` on
105the `Profile` tab of the `Settings` screen. If it is not set,
106propose a name and use `Select Username` to select the name.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800107
108To determine the port number Gerrit is running on, visit the special
109information URL `http://'hostname'/ssh_info`, and copy the port
110number from the second field:
111
Michael Ochmannb99feab2016-07-06 14:10:22 +0200112----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800113 $ curl http://hostname/ssh_info
114 hostname 29418
Michael Ochmannb99feab2016-07-06 14:10:22 +0200115----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800116
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800117If you are developing an automated tool to perform uploads to Gerrit,
118let the user supply the hostname or the web address for Gerrit,
119and obtain the port number on the fly from the `/ssh_info` URL.
120The returned output from this URL is always `'hostname' SP 'port'`,
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700121or `NOT_AVAILABLE` if the SSHD server is not currently running.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800122
123
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800124== git push
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800125
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700126[[push_create]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800127=== Create Changes
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800128
David Pursehouse221d4f62012-06-08 17:38:08 +0900129To create new changes for review, simply push to the project's
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800130magical `refs/for/'branch'` ref using any Git client tool:
131
Michael Ochmannb99feab2016-07-06 14:10:22 +0200132----
Shawn Pearce69928a62013-02-24 18:01:27 -0800133 git push ssh://sshusername@hostname:29418/projectname HEAD:refs/for/branch
Michael Ochmannb99feab2016-07-06 14:10:22 +0200134----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800135
136E.g. `john.doe` can use git push to upload new changes for the
137`experimental` branch of project `kernel/common`, hosted at the
138`git.example.com` Gerrit server:
139
Michael Ochmannb99feab2016-07-06 14:10:22 +0200140----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800141 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental
Michael Ochmannb99feab2016-07-06 14:10:22 +0200142----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800143
144Each new commit uploaded by the `git push` client will be
145converted into a change record on the server. The remote ref
146`refs/for/experimental` is not actually created by Gerrit, even
147though the client's status messages may say otherwise.
148
149Other users (e.g. project owners) who have configured Gerrit to
150notify them of new changes will be automatically sent an email
151message when the push is completed.
152
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900153[[push_options]]
154=== Push Options
155
156Additional options may be specified when pushing changes.
157
Edwin Kempin9e078d82016-01-29 10:56:07 +0100158[[notify]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900159==== Email Notifications
Edwin Kempin9e078d82016-01-29 10:56:07 +0100160
161Uploaders can control to whom email notifications are sent by setting
162the `notify` option:
163
164* `NONE`: No email notification will be sent to anyone.
165* `OWNER`: Only the change owner is notified.
166* `OWNER_REVIEWERS`: Only owners and reviewers will be notified. This
167 includes all reviewers, existing reviewers of the change and new
168 reviewers that are added by the `reviewer` option or by mentioning
169 in the commit message.
170* `ALL`: All email notifications will be sent. This includes
171 notifications to watchers, users that have starred the change, CCs
172 and the committer and author of the uploaded commit.
173
174By default all email notifications are sent.
175
Michael Ochmannb99feab2016-07-06 14:10:22 +0200176----
Edwin Kempin9e078d82016-01-29 10:56:07 +0100177 git push ssh://bot@git.example.com:29418/kernel/common HEAD:refs/for/master%notify=NONE
Michael Ochmannb99feab2016-07-06 14:10:22 +0200178----
Edwin Kempin9e078d82016-01-29 10:56:07 +0100179
Edwin Kempincd07df42016-12-01 09:10:09 +0100180In addition uploaders can explicitly specify accounts that should be
181notified, regardless of the value that is given for the `notify`
182option. To notify a specific account specify it by an
183`notify-to='email'`, `notify-cc='email'` or `notify-bcc='email'`
184option. These options can be specified as many times as necessary to
185cover all interested parties. Gerrit will automatically avoid sending
186duplicate email notifications, such as if one of the specified accounts
187had also requested to receive all new change notifications. The
188accounts that are specified by `notify-to='email'`, `notify-cc='email'`
189and `notify-bcc='email'` will only be notified about this one push.
190They are not added as link:#reviewers[reviewers or CCs], hence they are
191not automatically signed up to be notified on further updates of the
192change.
193
194----
195 git push ssh://bot@git.example.com:29418/kernel/common HEAD:refs/for/master%notify=NONE,notify-to=a@a.com
196----
197
Edwin Kempin1f556222015-04-22 13:24:39 +0200198[[topic]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900199==== Topic
200
Shawn O. Pearced50c94e2010-07-15 12:24:11 -0700201To include a short tag associated with all of the changes in the
202same group, such as the local topic branch name, append it after
Dan Wang17ced402016-08-26 16:42:49 -0700203the destination branch name or add it with the command line flag
204`--push-option`, aliased to `-o`. In this example the short topic
205tag 'driver/i42' will be saved on each change this push creates or
Shawn O. Pearced50c94e2010-07-15 12:24:11 -0700206updates:
207
Michael Ochmannb99feab2016-07-06 14:10:22 +0200208----
Shawn Pearce69928a62013-02-24 18:01:27 -0800209 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%topic=driver/i42
Dan Wang17ced402016-08-26 16:42:49 -0700210
211 // this is the same as:
212 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental -o topic=driver/i42
Michael Ochmannb99feab2016-07-06 14:10:22 +0200213----
Shawn O. Pearced50c94e2010-07-15 12:24:11 -0700214
Khai Do50eb94e2016-03-30 16:50:13 -0700215[[message]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900216==== Message
217
Khai Do50eb94e2016-03-30 16:50:13 -0700218A comment message can be applied to the change by using the `message` (or `m`)
219option:
220
Michael Ochmannb99feab2016-07-06 14:10:22 +0200221----
Khai Do50eb94e2016-03-30 16:50:13 -0700222 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%m=This_is_a_rebase_on_master
Michael Ochmannb99feab2016-07-06 14:10:22 +0200223----
Khai Do50eb94e2016-03-30 16:50:13 -0700224
Michael Ochmann8129ece2016-07-08 11:25:25 +0200225[NOTE]
Khai Do50eb94e2016-03-30 16:50:13 -0700226git push refs parameter does not allow spaces. Use the '_' character instead,
227it will then be applied as "This is a rebase on master".
Khai Do50eb94e2016-03-30 16:50:13 -0700228
Gustaf Lundh48191712014-10-03 10:29:59 +0200229[[review_labels]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900230==== Review Labels
231
David Pursehouse93733b62014-10-03 12:26:04 +0900232Review labels can be applied to the change by using the `label` (or `l`)
233option in the reference:
Gustaf Lundhe235a062014-10-03 10:29:59 +0200234
Michael Ochmannb99feab2016-07-06 14:10:22 +0200235----
Gustaf Lundhe235a062014-10-03 10:29:59 +0200236 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%l=Verified+1
Michael Ochmannb99feab2016-07-06 14:10:22 +0200237----
Gustaf Lundhe235a062014-10-03 10:29:59 +0200238
239The `l='label[score]'` option may be specified more than once to
240apply multiple review labels.
241
Michael Ochmannb99feab2016-07-06 14:10:22 +0200242----
Khai Do4bea1c62016-02-08 10:02:49 -0800243 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%l=Code-Review+1,l=Verified+1
Michael Ochmannb99feab2016-07-06 14:10:22 +0200244----
Khai Do4bea1c62016-02-08 10:02:49 -0800245
Gustaf Lundhe235a062014-10-03 10:29:59 +0200246The value is optional. If not specified, it defaults to +1 (if
247the label range allows it).
248
David Ostrovskyd07bb3392015-01-19 07:43:44 +0100249[[change_edit]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900250==== Change Edits
251
David Ostrovskyd07bb3392015-01-19 07:43:44 +0100252A change edit can be pushed by specifying the `edit` (or `e`) option on
253the reference:
254
Michael Ochmannb99feab2016-07-06 14:10:22 +0200255----
David Ostrovskyd07bb3392015-01-19 07:43:44 +0100256 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%edit
Michael Ochmannb99feab2016-07-06 14:10:22 +0200257----
David Ostrovskyd07bb3392015-01-19 07:43:44 +0100258
259There is at most one change edit per user and change. In order to push
260a change edit the change must already exist.
261
262[NOTE]
263When a change edit already exists for a change then pushing with
264`%edit` replaces the existing change edit. This option is useful to
265rebase a change edit on the newest patch set when the rebase of the
266change edit in the web UI fails due to conflicts.
267
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800268If you are frequently uploading changes to the same Gerrit server,
269consider adding an SSH host block in `~/.ssh/config` to remember
270your username, hostname and port number. This permits the use of
271shorter URLs on the command line, such as:
272
Michael Ochmannb99feab2016-07-06 14:10:22 +0200273----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800274 $ cat ~/.ssh/config
275 ...
276 Host tr
277 Hostname git.example.com
278 Port 29418
279 User john.doe
280
281 $ git push tr:kernel/common HEAD:refs/for/experimental
Michael Ochmannb99feab2016-07-06 14:10:22 +0200282----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800283
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900284[[reviewers]]
285==== Reviewers
286
Edwin Kempinb5df3b82011-10-10 11:31:14 +0200287Specific reviewers can be requested and/or additional 'carbon
David Pursehouse93733b62014-10-03 12:26:04 +0900288copies' of the notification message may be sent by including the
289`reviewer` (or `r`) and `cc` options in the reference:
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800290
Michael Ochmannb99feab2016-07-06 14:10:22 +0200291----
Shawn Pearce69928a62013-02-24 18:01:27 -0800292 git push tr:kernel/common HEAD:refs/for/experimental%r=a@a.com,cc=b@o.com
Michael Ochmannb99feab2016-07-06 14:10:22 +0200293----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800294
Shawn Pearce69928a62013-02-24 18:01:27 -0800295The `r='email'` and `cc='email'` options may be specified as many
296times as necessary to cover all interested parties. Gerrit will
297automatically avoid sending duplicate email notifications, such as
298if one of the specified reviewers or CC addresses had also requested
299to receive all new change notifications.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800300
301If you are frequently sending changes to the same parties and/or
302branches, consider adding a custom remote block to your project's
303`.git/config` file:
304
Michael Ochmannb99feab2016-07-06 14:10:22 +0200305----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800306 $ cat .git/config
307 ...
Shawn Pearce69928a62013-02-24 18:01:27 -0800308 [remote "exp"]
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800309 url = tr:kernel/common
Shawn Pearce69928a62013-02-24 18:01:27 -0800310 push = HEAD:refs/for/experimental%r=a@a.com,cc=b@o.com
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800311
Shawn Pearce69928a62013-02-24 18:01:27 -0800312 $ git push exp
Michael Ochmannb99feab2016-07-06 14:10:22 +0200313----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800314
315
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700316[[push_replace]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800317=== Replace Changes
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700318
319To add an additional patch set to a change, ensure Change-Id
320lines were created in the original commit messages, and just use
321`git push URL HEAD:refs/for/...` as <<push_create,described above>>.
322Gerrit Code Review will automatically match the commits back to
323their original changes by taking advantage of the Change-Id lines.
324
325If Change-Id lines are not present in the commit messages, consider
326amending the message and copying the line from the change's page
327on the web, and then using `git push` as described above.
328
329If Change-Id lines are not available, then the user must use the
330manual mapping technique described below.
331
332For more about Change-Ids, see link:user-changeid.html[Change-Id Lines].
333
Edwin Kempin930187e2011-01-27 10:13:42 +0100334[[manual_replacement_mapping]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800335==== Manual Replacement Mapping
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700336
Michael Ochmann8129ece2016-07-08 11:25:25 +0200337[NOTE]
338--
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700339The remainder of this section describes a manual method of replacing
340changes by matching each commit name to an existing change number.
341End-users should instead prefer to use Change-Id lines in their
342commit messages, as the process is then fully automated by Gerrit
343during normal uploads.
344
345See above for the preferred technique of replacing changes.
Michael Ochmann8129ece2016-07-08 11:25:25 +0200346--
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800347
348To add an additional patch set to a change, replacing it with an
349updated version of the same logical modification, send the new
350commit to the change's ref. For example, to add the commit whose
351SHA-1 starts with `c0ffee` as a new patch set for change number
352`1979`, use the push refspec `c0ffee:refs/changes/1979` as below:
353
Michael Ochmannb99feab2016-07-06 14:10:22 +0200354----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800355 git push ssh://sshusername@hostname:29418/projectname c0ffee:refs/changes/1979
Michael Ochmannb99feab2016-07-06 14:10:22 +0200356----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800357
358This form can be combined together with `refs/for/'branchname'`
359(above) to simultaneously create new changes and replace changes
360during one network transaction.
361
362For example, consider the following sequence of events:
363
Michael Ochmannb99feab2016-07-06 14:10:22 +0200364----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800365 $ git commit -m A ; # create 3 commits
366 $ git commit -m B
367 $ git commit -m C
368
369 $ git push ... HEAD:refs/for/master ; # upload for review
370 ... A is 1500 ...
371 ... B is 1501 ...
372 ... C is 1502 ...
373
374 $ git rebase -i HEAD~3 ; # edit "A", insert D before B
375 ; # now series is A'-D-B'-C'
Shawn O. Pearced6078462009-11-02 10:37:01 -0800376 $ git push ...
377 HEAD:refs/for/master
378 HEAD~3:refs/changes/1500
379 HEAD~1:refs/changes/1501
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800380 HEAD~0:refs/changes/1502 ; # upload replacements
Michael Ochmannb99feab2016-07-06 14:10:22 +0200381----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800382
383At the final step during the push Gerrit will attach A' as a new
384patch set on change 1500; B' as a new patch set on change 1501; C'
385as a new patch set on 1502; and D will be created as a new change.
386
387Ensuring D is created as a new change requires passing the refspec
388`HEAD:refs/for/branchname`, otherwise Gerrit will ignore D and
389won't do anything with it. For this reason it is a good idea to
390always include the create change refspec when uploading replacements.
391
392
Edwin Kempin913eab12011-05-06 08:18:24 +0200393[[bypass_review]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800394=== Bypass Review
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800395
396Changes (and annotated tags) can be pushed directly into a
397repository, bypassing the review process. This is primarily useful
398for a project owner to create new branches, create annotated tags
399for releases, or to force-update a branch whose history needed to
400be rewritten.
401
402Gerrit restricts direct pushes that bypass review to:
403
Jonathan Nieder5758f182015-03-30 11:28:55 -0700404* `+refs/heads/*+`: any branch can be updated, created, deleted,
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800405or rewritten by the pusher.
Jonathan Nieder5758f182015-03-30 11:28:55 -0700406* `+refs/tags/*+`: annotated tag objects pointing to any other type
Nico Sallembien950e4152010-03-16 15:45:33 -0700407of Git object can be created.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800408
Fredrik Luthanderc10f9e72012-01-23 17:00:45 +0100409To push branches, the proper access rights must be configured first.
410Here follows a few examples of how to configure this in Gerrit:
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800411
412* Update: Any existing branch can be fast-forwarded to a new commit.
413This is the safest mode as commits cannot be discarded. Creation
Fredrik Luthanderc10f9e72012-01-23 17:00:45 +0100414of new branches is rejected. Can be configured with
415link:access-control.html#category_push_direct['Push'] access.
416* Create: Allows creation of a new branch if the name does not
417already designate an existing branch name. Needs
418link:access-control.html#category_create['Create Reference']
419configured. Please note that once created, this permission doesn't
420grant the right to update the branch with further commits (see above
421for update details).
422* Delete: Implies Update, but also allows an existing
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800423branch to be deleted. Since a force push is effectively a delete
424followed by a create, but performed atomically on the server and
425logged, this also permits forced push updates to branches.
Fredrik Luthanderc10f9e72012-01-23 17:00:45 +0100426To grant this access, configure
427link:access-control.html#category_push_direct['Push'] with the
428'Force' option ticked.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800429
Edwin Kempin62c15682016-09-05 14:32:38 +0200430To push annotated tags, the `Create Annotated Tag` project right must
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800431be granted to one (or more) of the user's groups. There is only
432one level of access in this category.
433
Edwin Kempin62c15682016-09-05 14:32:38 +0200434Project owners may wish to grant themselves `Create Annotated Tag`
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800435only at times when a new release is being prepared, and otherwise
436grant nothing at all. This ensures that accidental pushes don't
437make undesired changes to the public repository.
438
439
Edwin Kempinbfa06212013-04-04 16:06:39 +0200440[[auto_merge]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800441=== Auto-Merge during Push
Edwin Kempinbfa06212013-04-04 16:06:39 +0200442
443Changes can be directly submitted on push. This is primarily useful
444for teams that don't want to do code review but want to use Gerrit's
445submit strategies to handle contention on busy branches. Using
Sebastian Schuberth8329b012016-03-15 14:48:33 +0100446`%submit` creates a change and submits it immediately:
Edwin Kempinbfa06212013-04-04 16:06:39 +0200447
Michael Ochmannb99feab2016-07-06 14:10:22 +0200448----
Edwin Kempinbfa06212013-04-04 16:06:39 +0200449 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%submit
Michael Ochmannb99feab2016-07-06 14:10:22 +0200450----
Edwin Kempinbfa06212013-04-04 16:06:39 +0200451
452On auto-merge of a change neither labels nor submit rules are checked.
453If the merge fails the change stays open, but when pushing a new patch
454set the merge can be reattempted by using `%submit` again.
455
Sebastian Schuberth8329b012016-03-15 14:48:33 +0100456This requires the caller to have link:access-control.html#category_submit[Submit]
457permission on `refs/for/<ref>` (e.g. on `refs/for/refs/heads/master`).
458Note how this is different from the `Submit` permission on `refs/heads/<ref>`,
459and in particular you typically do not want to apply the `Submit` permission
460on `refs/*` (unless you are ok with bypassing submit rules).
Edwin Kempinbfa06212013-04-04 16:06:39 +0200461
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700462[[base]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800463=== Selecting Merge Base
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700464
465By default new changes are opened only for new unique commits
466that have never before been seen by the Gerrit server. Clients
467may override that behavior and force new changes to be created
468by setting the merge base SHA-1 using the '%base' argument:
469
Michael Ochmannb99feab2016-07-06 14:10:22 +0200470----
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700471 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=$(git rev-parse origin/master)
Michael Ochmannb99feab2016-07-06 14:10:22 +0200472----
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700473
Sasa Zivkovbc011a12013-11-07 16:08:31 +0100474It is also possible to specify more than one '%base' argument.
475This may be useful when pushing a merge commit. Note that the '%'
476character has only to be provided once, for the first '%base'
477argument:
478
Michael Ochmannb99feab2016-07-06 14:10:22 +0200479----
Sasa Zivkovbc011a12013-11-07 16:08:31 +0100480 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=commit-id1,base=commit-id2
Michael Ochmannb99feab2016-07-06 14:10:22 +0200481----
Sasa Zivkovbc011a12013-11-07 16:08:31 +0100482
Dave Borowitza01219a2016-09-09 10:18:26 -0400483[[merged]]
484=== Creating Changes for Merged Commits
485
486Normally, changes are only created for commits that have not yet
487been merged into the branch. In some cases, you may want to review a
488change that has already been merged. A new change for a merged commit
489can be created by using the '%merged' argument:
490
491----
492 git push ssh://john.doe@git.example.com:29418/kernel/common my-merged-commit:refs/for/master%merged
493----
494
495This only creates one merged change at a time, corresponding to
496exactly `my-merged-commit`. It doesn't walk all of history up to that
497point, which could be slow and create lots of unintended new changes.
498To create multiple new changes, run push multiple times.
499
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700500
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800501== repo upload
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700502
503repo is a multiple repository management tool, most commonly
504used by the Android Open Source Project. For more details, see
Orgad Shanehc9e11de2012-12-24 16:49:09 +0200505link:http://source.android.com/source/using-repo.html[using repo].
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700506
507[[repo_create]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800508=== Create Changes
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700509
510To upload changes to a project using `repo`, ensure the manifest's
511review field has been configured to point to the Gerrit server.
512Only the hostname or the web address needs to be given in the
513manifest file. During upload `repo` will automatically determine the
514correct port number by reading `http://'reviewhostname'/ssh_info`
515when its invoked.
516
517Each new commit uploaded by `repo upload` will be converted into
518a change record on the server. Other users (e.g. project owners)
519who have configured Gerrit to notify them of new changes will be
520automatically sent an email message. Additional notifications can
521be sent through command line options.
522
523For more details on using `repo upload`, see `repo help upload`.
524
525[[repo_replace]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800526=== Replace Changes
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700527
528To replace changes, ensure Change-Id lines were created in the
Cecilia Svenssoncd2491d2012-01-20 14:22:30 +0100529commit messages, and just use `repo upload`.
530Gerrit Code Review will automatically match the commits back to
531their original changes by taking advantage of their Change-Id lines.
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700532
533If Change-Id lines are not present in the commit messages, consider
534amending the message and copying the line from the change's page
535on the web.
536
537If Change-Id lines are not available, then the user must use the much
Cecilia Svenssoncd2491d2012-01-20 14:22:30 +0100538more <<manual_replacement_mapping,manual mapping technique>> offered
539by using `git push` to a specific `refs/changes/change#` reference.
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700540
541For more about Change-Ids, see link:user-changeid.html[Change-Id Lines].
542
543
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800544== Gritty Details
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800545
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800546As Gerrit implements the entire SSH and Git server stack within its
547own process space, Gerrit maintains complete control over how the
548repository is updated, and what responses are sent to the `git push`
549client invoked by the end-user, or by `repo upload`. This allows
Jonathan Nieder5758f182015-03-30 11:28:55 -0700550Gerrit to provide magical refs, such as `+refs/for/*+` for new
551change submission and `+refs/changes/*+` for change replacement.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800552When a push request is received to create a ref in one of these
553namespaces Gerrit performs its own logic to update the database,
554and then lies to the client about the result of the operation.
555A successful result causes the client to believe that Gerrit has
556created the ref, but in reality Gerrit hasn't created the ref at all.
557
558By implementing the entire server stack, Gerrit is also able to
559perform project level access control checks (to verify the end-user
560is permitted to access a project) prior to advertising the available
561refs, and potentially leaking information to a snooping client.
562Clients cannot tell the difference between 'project not found' and
563'project exists, but access is denied'.
564
565Gerrit can also ensure users have completed a valid Contributor
566Agreement prior to accepting any transferred objects, and if an
567agreement is required, but not completed, it aborts the network
568connection before data is sent. This ensures that project owners
569can be certain any object available in their repository has been
570supplied under at least one valid agreement.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700571
572GERRIT
573------
574Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700575
576SEARCHBOX
577---------