blob: 8c51207584f6e65a7e5230b7781456407405567d [file] [log] [blame]
Marian Harbachebeb1542019-12-13 10:42:46 +01001:linkattrs:
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08002= Gerrit Code Review - Uploading Changes
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -08003
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -07004Gerrit supports three methods of uploading changes:
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -08005
6* Use `repo upload`, to create changes for review
7* Use `git push`, to create changes for review
8* Use `git push`, and bypass code review
9
David Pursehousebaac4252013-01-25 17:42:19 +090010All three methods rely on authentication, which must first be configured
11by the uploading user.
12
Gert van Dijkdc4f8d12017-08-27 21:14:23 +020013Gerrit supports two protocols for uploading changes; SSH and HTTP/HTTPS. These
14may not all be available for you, depending on the server configuration.
David Pursehousebaac4252013-01-25 17:42:19 +090015
Edwin Kempin60ab8532013-03-27 14:33:46 +010016[[http]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080017== HTTP/HTTPS
David Pursehousebaac4252013-01-25 17:42:19 +090018
19On Gerrit installations that do not support SSH authentication, the
20user must authenticate via HTTP/HTTPS.
21
Han-Wen Nienhuys84d830b2017-02-15 16:36:04 +010022The user is authenticated using standard BasicAuth. Depending on the
23value of link:#auth.gitBasicAuthPolicy[auth.gitBasicAuthPolicy],
24credentials are validated using:
David Pursehousebaac4252013-01-25 17:42:19 +090025
Hector Oswaldo Caballero2a9ad1f2016-09-15 18:24:42 -040026* The randomly generated HTTP password on the `HTTP Password` tab
27 in the user settings page if `gitBasicAuthPolicy` is `HTTP`.
28* The LDAP password if `gitBasicAuthPolicy` is `LDAP`
29* Both, the HTTP and the LDAP passwords (in this order) if `gitBasicAuthPolicy`
30 is `HTTP_LDAP`.
31
Luca Milanesio1a918712021-05-06 20:20:48 +010032When gitBasicAuthPolicy is set to `LDAP` or `HTTP_LDAP` and the user
33is authenticating with the LDAP username/password, the Git client config
34needs to have `http.cookieFile` set to a local file, otherwise every
35single call would trigger a full LDAP authentication and groups resolution
36which could introduce a noticeable latency on the overall execution
37and produce unwanted load to the LDAP server.
38
Han-Wen Nienhuys84d830b2017-02-15 16:36:04 +010039When gitBasicAuthPolicy is not `LDAP`, the user's HTTP credentials can
40be regenerated by going to `Settings`, and then accessing the `HTTP
41Password` tab. Revocation can effectively be done by regenerating the
42password and then forgetting it.
David Pursehousebaac4252013-01-25 17:42:19 +090043
44For Gerrit installations where an link:config-gerrit.html#auth.httpPasswordUrl[HTTP password URL]
45is configured, the password can be obtained by clicking on `Obtain Password`
46and then following the site-specific instructions. On sites where this URL is
47not configured, the password can be obtained by clicking on `Generate Password`.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080048
Edwin Kempin1f556222015-04-22 13:24:39 +020049[[ssh]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080050== SSH
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080051
Gert van Dijkdc4f8d12017-08-27 21:14:23 +020052To upload changes over SSH, Gerrit supports two forms of authentication: a
53user's public key or kerberos.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080054
Gert van Dijkdc4f8d12017-08-27 21:14:23 +020055Unless your Gerrit instance is configured to support
56link:config-gerrit.html#sshd.kerberosKeytab[kerberos] in your domain, only
57public key authentication can be used.
58
59[[configure_ssh_public_keys]]
60=== Public keys
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080061
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070062To register a new SSH key for use with Gerrit, paste the contents of
63your `id_rsa.pub` or `id_dsa.pub` file into the text box and click
64the add button. Gerrit only understands SSH version 2 public keys.
65Keys may be supplied in either the OpenSSH format (key starts with
66`ssh-rsa` or `ssh-dss`) or the RFC 4716 format (file starts with
67`---- BEGIN SSH2 PUBLIC KEY ----`).
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080068
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070069Typically SSH keys are stored in your home directory, under `~/.ssh`.
70If you don't have any keys yet, you can create a new one and protect
71it with a passphrase:
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080072
Michael Ochmannb99feab2016-07-06 14:10:22 +020073----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080074 ssh-keygen -t rsa
Michael Ochmannb99feab2016-07-06 14:10:22 +020075----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080076
77Then copy the content of the public key file onto your clipboard,
78and paste it into Gerrit's web interface:
79
Michael Ochmannb99feab2016-07-06 14:10:22 +020080----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080081 cat ~/.ssh/id_rsa.pub
Michael Ochmannb99feab2016-07-06 14:10:22 +020082----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080083
84[TIP]
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070085Users who frequently upload changes will also want to consider
David Pursehouse221d4f62012-06-08 17:38:08 +090086starting an `ssh-agent`, and adding their private key to the list
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -070087managed by the agent, to reduce the frequency of entering the
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -080088key's passphrase. Consult `man ssh-agent`, or your SSH client's
89documentation, for more details on configuration of the agent
90process and how to add the private key.
91
Gert van Dijkdc4f8d12017-08-27 21:14:23 +020092[[configure_ssh_kerberos]]
93=== Kerberos
94
95A kerberos-enabled server configuration allows for zero configuration in an
96existing single-sign-on environment.
97
98Your SSH client should be configured to enable kerberos authentication. For
99OpenSSH clients, this is controlled by the option `GSSAPIAuthentication` which
100should be set to `yes`.
101
102Some Linux distributions have packaged OpenSSH to enable this by default (e.g.
103Debian, Ubuntu). If this is not the case for your distribution, enable it for
104Gerrit with this entry in your local SSH configuration:
105
106----
Gert van Dijk1415f072017-08-28 20:33:56 +0200107 Host gerrit.mydomain.tld
108 GSSAPIAuthentication yes
Gert van Dijkdc4f8d12017-08-27 21:14:23 +0200109----
110
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700111[[test_ssh]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800112=== Testing Connections
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800113
Gert van Dijkdc4f8d12017-08-27 21:14:23 +0200114To verify your SSH authentication is working correctly, try using an SSH client
David Pursehouse221d4f62012-06-08 17:38:08 +0900115to connect to Gerrit's SSHD port. By default Gerrit runs on
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800116port 29418, using the same hostname as the web server:
117
Michael Ochmannb99feab2016-07-06 14:10:22 +0200118----
Hugo Arès93ef4272016-03-01 21:50:41 -0500119 $ ssh -p 29418 sshusername@hostname
Edwin Kempinfb95a1b2011-10-05 10:08:00 +0200120
121 **** Welcome to Gerrit Code Review ****
122
123 Hi John Doe, you have successfully connected over SSH.
124
125 Unfortunately, interactive shells are disabled.
126 To clone a hosted Git repository, use:
127
128 git clone ssh://sshusername@hostname:29418/REPOSITORY_NAME.git
129
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800130 Connection to hostname closed.
Michael Ochmannb99feab2016-07-06 14:10:22 +0200131----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800132
Edwin Kempinfb95a1b2011-10-05 10:08:00 +0200133In the command above, `sshusername` was configured as `Username` on
134the `Profile` tab of the `Settings` screen. If it is not set,
135propose a name and use `Select Username` to select the name.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800136
137To determine the port number Gerrit is running on, visit the special
138information URL `http://'hostname'/ssh_info`, and copy the port
139number from the second field:
140
Michael Ochmannb99feab2016-07-06 14:10:22 +0200141----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800142 $ curl http://hostname/ssh_info
143 hostname 29418
Michael Ochmannb99feab2016-07-06 14:10:22 +0200144----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800145
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800146If you are developing an automated tool to perform uploads to Gerrit,
147let the user supply the hostname or the web address for Gerrit,
148and obtain the port number on the fly from the `/ssh_info` URL.
149The returned output from this URL is always `'hostname' SP 'port'`,
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700150or `NOT_AVAILABLE` if the SSHD server is not currently running.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800151
Gert van Dijk1415f072017-08-28 20:33:56 +0200152[[configure_ssh_host_entry]]
153=== OpenSSH Host entry
154
155If you are frequently uploading changes to the same Gerrit server, consider
156adding an SSH `Host` entry in your OpenSSH client configuration
157(`~/.ssh/config`) for that Gerrit server. It allows you use a single alias
158defining your username, hostname and port number whenever you're accessing
159this Gerrit server in an SSH context (also command line SSH or SCP). Use this
160for easier to remember, shorter URLs, e.g.:
161
162----
163 $ cat ~/.ssh/config
164 ...
165 Host mygerrit
166 Hostname git.example.com
167 Port 29418
168 User john.doe
169
170 $ git clone mygerrit:myproject
171
172 $ ssh mygerrit gerrit version
173
174 $ scp -p mygerrit:hooks/commit-msg .git/hooks/
175----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800176
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800177== git push
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800178
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700179[[push_create]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800180=== Create Changes
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800181
David Pursehouse221d4f62012-06-08 17:38:08 +0900182To create new changes for review, simply push to the project's
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800183magical `refs/for/'branch'` ref using any Git client tool:
184
Michael Ochmannb99feab2016-07-06 14:10:22 +0200185----
Shawn Pearce69928a62013-02-24 18:01:27 -0800186 git push ssh://sshusername@hostname:29418/projectname HEAD:refs/for/branch
Michael Ochmannb99feab2016-07-06 14:10:22 +0200187----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800188
189E.g. `john.doe` can use git push to upload new changes for the
190`experimental` branch of project `kernel/common`, hosted at the
191`git.example.com` Gerrit server:
192
Michael Ochmannb99feab2016-07-06 14:10:22 +0200193----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800194 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental
Michael Ochmannb99feab2016-07-06 14:10:22 +0200195----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800196
197Each new commit uploaded by the `git push` client will be
198converted into a change record on the server. The remote ref
199`refs/for/experimental` is not actually created by Gerrit, even
200though the client's status messages may say otherwise.
201
202Other users (e.g. project owners) who have configured Gerrit to
203notify them of new changes will be automatically sent an email
204message when the push is completed.
205
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900206[[push_options]]
207=== Push Options
208
209Additional options may be specified when pushing changes.
210
Edwin Kempin9e078d82016-01-29 10:56:07 +0100211[[notify]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900212==== Email Notifications
Edwin Kempin9e078d82016-01-29 10:56:07 +0100213
214Uploaders can control to whom email notifications are sent by setting
215the `notify` option:
216
217* `NONE`: No email notification will be sent to anyone.
218* `OWNER`: Only the change owner is notified.
219* `OWNER_REVIEWERS`: Only owners and reviewers will be notified. This
220 includes all reviewers, existing reviewers of the change and new
221 reviewers that are added by the `reviewer` option or by mentioning
222 in the commit message.
223* `ALL`: All email notifications will be sent. This includes
224 notifications to watchers, users that have starred the change, CCs
225 and the committer and author of the uploaded commit.
226
227By default all email notifications are sent.
228
Michael Ochmannb99feab2016-07-06 14:10:22 +0200229----
Edwin Kempin9e078d82016-01-29 10:56:07 +0100230 git push ssh://bot@git.example.com:29418/kernel/common HEAD:refs/for/master%notify=NONE
Michael Ochmannb99feab2016-07-06 14:10:22 +0200231----
Edwin Kempin9e078d82016-01-29 10:56:07 +0100232
Edwin Kempincd07df42016-12-01 09:10:09 +0100233In addition uploaders can explicitly specify accounts that should be
234notified, regardless of the value that is given for the `notify`
235option. To notify a specific account specify it by an
236`notify-to='email'`, `notify-cc='email'` or `notify-bcc='email'`
237option. These options can be specified as many times as necessary to
238cover all interested parties. Gerrit will automatically avoid sending
239duplicate email notifications, such as if one of the specified accounts
240had also requested to receive all new change notifications. The
241accounts that are specified by `notify-to='email'`, `notify-cc='email'`
242and `notify-bcc='email'` will only be notified about this one push.
243They are not added as link:#reviewers[reviewers or CCs], hence they are
244not automatically signed up to be notified on further updates of the
245change.
246
247----
248 git push ssh://bot@git.example.com:29418/kernel/common HEAD:refs/for/master%notify=NONE,notify-to=a@a.com
249----
250
Edwin Kempin1f556222015-04-22 13:24:39 +0200251[[topic]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900252==== Topic
253
Dave Borowitz190cbd62018-03-15 10:35:59 -0400254To include a short link:intro-user.html#topics[topic] associated with all
255of the changes in the same group, such as the local topic branch name,
256append it after the destination branch name or add it with the command line
257flag `--push-option`, aliased to `-o`. In this example the short topic name
258'driver/i42' will be saved on each change this push creates or updates:
Shawn O. Pearced50c94e2010-07-15 12:24:11 -0700259
Michael Ochmannb99feab2016-07-06 14:10:22 +0200260----
Shawn Pearce69928a62013-02-24 18:01:27 -0800261 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 -0700262
263 // this is the same as:
264 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 +0200265----
Shawn O. Pearced50c94e2010-07-15 12:24:11 -0700266
Dave Borowitz190cbd62018-03-15 10:35:59 -0400267[[hashtag]]
268==== Hashtag
269
270To include a link:intro-user.html#hashtags[hashtag] associated with all of the
271changes in the same group, use the `hashtag` or `t` option:
272
273----
274 // these are all equivalent
275 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%hashtag=stable-fix
276 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%t=stable-fix
277 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental -o hashtag=stable-fix
278 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental -o t=stable-fix
279----
280
Edwin Kempin98ddc8a2017-02-21 11:56:08 +0100281[[private]]
282==== Private Changes
283
284To push a private change or to turn a change private on push the `private`
285option can be specified:
286
287----
288 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%private
289----
290
291Omitting the `private` option when pushing updates to a private change
292doesn't make change non-private again. To remove the private
293flag from a change on push, explicitly specify the `remove-private` option:
294
295----
296 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%remove-private
297----
298
David Ostrovsky98b27bd2017-04-02 15:25:20 +0200299[[wip]]
300==== Work-In-Progress Changes
301
302To push a wip change or to turn a change to wip the `work-in-progress` (or `wip`)
303option can be specified:
304
305----
306 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%wip
307----
308
309Omitting the `wip` option when pushing updates to a wip change
310doesn't make change ready again. To remove the `wip`
311flag from a change on push, explicitly specify the `ready` option:
312
313----
314 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%ready
315----
316
David Ostrovsky44242452018-06-09 20:25:13 +0200317Only change owners, project owners and site administrators can specify
318`work-in-progress` and `ready` options on push.
319
David Ostrovsky821c5322018-06-10 16:36:42 +0200320The default for this option can be set as a
321link:intro-user.html#work-in-progress-by-default[user preference]. If the
322preference is set so the default behavior is to create `work-in-progress`
323changes, this can be overridden with the `ready` option.
324
Sven Selbergf4435b02020-11-05 11:00:33 +0100325[[patch_set_description]]
326==== Patch Set Description
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900327
Sven Selbergf4435b02020-11-05 11:00:33 +0100328A link:concept-patch-sets.html#_description[patch set description] can be
329applied by using the `message` (or `m`) option:
Khai Do50eb94e2016-03-30 16:50:13 -0700330
Michael Ochmannb99feab2016-07-06 14:10:22 +0200331----
Nick Carter83010b52017-10-30 12:54:42 -0700332 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%m=This_is_a_rebase_on_master%21
Michael Ochmannb99feab2016-07-06 14:10:22 +0200333----
Khai Do50eb94e2016-03-30 16:50:13 -0700334
Michael Ochmann8129ece2016-07-08 11:25:25 +0200335[NOTE]
Nick Carter83010b52017-10-30 12:54:42 -0700336git push refs parameter does not allow spaces. Use the '_' or '+' character
337to represent spaces, and percent-encoding to represent other special chars.
338The above example will thus be applied as "This is a rebase on master!"
339
340To avoid confusion in parsing the git ref, at least the following characters
341must be percent-encoded: " %^@.~-+_:/!". Note that some of the reserved
342characters (like tilde) are not escaped in the standard URL encoding rules,
Mike Frysinger63367442022-05-20 05:37:40 -0400343so a language-provided function (e.g. encodeURIComponent(), in JavaScript)
Nick Carter83010b52017-10-30 12:54:42 -0700344might not suffice. To be safest, you might consider percent-encoding all
345non-alphanumeric characters (and all multibyte UTF-8 code points).
Khai Do50eb94e2016-03-30 16:50:13 -0700346
Dave Borowitzcb861922017-04-27 06:12:02 -0400347[[publish-comments]]
348==== Publish Draft Comments
349
350If you have draft comments on the change(s) that are updated by the push, the
351`publish-comments` option will cause them to be published:
352
353----
354 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%publish-comments
355----
356
Dave Borowitzd6ee48e2017-04-27 10:32:42 -0400357The default for this option can be set as a
358link:intro-user.html#publish-comments-on-push[user preference]. If the
359preference is set so the default behavior is to publish, this can be overridden
360with the `no-publish-comments` (or `np`) option.
361
Gustaf Lundh48191712014-10-03 10:29:59 +0200362[[review_labels]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900363==== Review Labels
364
David Pursehouse93733b62014-10-03 12:26:04 +0900365Review labels can be applied to the change by using the `label` (or `l`)
366option in the reference:
Gustaf Lundhe235a062014-10-03 10:29:59 +0200367
Michael Ochmannb99feab2016-07-06 14:10:22 +0200368----
Gustaf Lundhe235a062014-10-03 10:29:59 +0200369 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 +0200370----
Gustaf Lundhe235a062014-10-03 10:29:59 +0200371
372The `l='label[score]'` option may be specified more than once to
373apply multiple review labels.
374
Michael Ochmannb99feab2016-07-06 14:10:22 +0200375----
Khai Do4bea1c62016-02-08 10:02:49 -0800376 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 +0200377----
Khai Do4bea1c62016-02-08 10:02:49 -0800378
Gustaf Lundhe235a062014-10-03 10:29:59 +0200379The value is optional. If not specified, it defaults to +1 (if
380the label range allows it).
381
David Ostrovskyd07bb3392015-01-19 07:43:44 +0100382[[change_edit]]
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900383==== Change Edits
384
David Ostrovskyd07bb3392015-01-19 07:43:44 +0100385A change edit can be pushed by specifying the `edit` (or `e`) option on
386the reference:
387
Michael Ochmannb99feab2016-07-06 14:10:22 +0200388----
David Ostrovskyd07bb3392015-01-19 07:43:44 +0100389 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%edit
Michael Ochmannb99feab2016-07-06 14:10:22 +0200390----
David Ostrovskyd07bb3392015-01-19 07:43:44 +0100391
392There is at most one change edit per user and change. In order to push
393a change edit the change must already exist.
394
395[NOTE]
396When a change edit already exists for a change then pushing with
397`%edit` replaces the existing change edit. This option is useful to
398rebase a change edit on the newest patch set when the rebase of the
399change edit in the web UI fails due to conflicts.
400
David Pursehouse06eb3eb2016-09-01 11:04:03 +0900401[[reviewers]]
402==== Reviewers
403
Edwin Kempinb5df3b82011-10-10 11:31:14 +0200404Specific reviewers can be requested and/or additional 'carbon
David Pursehouse93733b62014-10-03 12:26:04 +0900405copies' of the notification message may be sent by including the
406`reviewer` (or `r`) and `cc` options in the reference:
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800407
Michael Ochmannb99feab2016-07-06 14:10:22 +0200408----
Gert van Dijk1415f072017-08-28 20:33:56 +0200409 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%r=a@a.com,cc=b@o.com
Michael Ochmannb99feab2016-07-06 14:10:22 +0200410----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800411
Shawn Pearce69928a62013-02-24 18:01:27 -0800412The `r='email'` and `cc='email'` options may be specified as many
413times as necessary to cover all interested parties. Gerrit will
414automatically avoid sending duplicate email notifications, such as
415if one of the specified reviewers or CC addresses had also requested
416to receive all new change notifications.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800417
418If you are frequently sending changes to the same parties and/or
419branches, consider adding a custom remote block to your project's
420`.git/config` file:
421
Michael Ochmannb99feab2016-07-06 14:10:22 +0200422----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800423 $ cat .git/config
424 ...
Shawn Pearce69928a62013-02-24 18:01:27 -0800425 [remote "exp"]
Gert van Dijk1415f072017-08-28 20:33:56 +0200426 url = ssh://john.doe@git.example.com:29418/kernel/common
Shawn Pearce69928a62013-02-24 18:01:27 -0800427 push = HEAD:refs/for/experimental%r=a@a.com,cc=b@o.com
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800428
Shawn Pearce69928a62013-02-24 18:01:27 -0800429 $ git push exp
Michael Ochmannb99feab2016-07-06 14:10:22 +0200430----
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800431
Edwin Kempin0ade5aa2018-08-10 08:49:32 +0200432[[trace]]
433==== Trace
434
Edwin Kempinda823782018-08-29 22:52:54 +0200435When pushing to Gerrit tracing can be enabled by setting the
436`trace=<trace-id>` push option. It is recommended to use the ID of the
437issue that is being investigated as trace ID.
Edwin Kempin0ade5aa2018-08-10 08:49:32 +0200438
439----
Edwin Kempinda823782018-08-29 22:52:54 +0200440 git push -o trace=issue/123 ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master
441----
442
443It is also possible to omit the trace ID and get a unique trace ID
444generated.
445
446.Example Request
447----
Edwin Kempin8b7376b2018-08-29 08:38:30 +0200448 git push -o trace ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master
Edwin Kempin0ade5aa2018-08-10 08:49:32 +0200449----
450
451Enabling tracing results in additional logs with debug information that
452are written to the `error_log`. All logs that correspond to the traced
Edwin Kempinda823782018-08-29 22:52:54 +0200453request are associated with the trace ID. This trace ID is returned in
454the command output:
Edwin Kempin0ade5aa2018-08-10 08:49:32 +0200455
456----
457 remote: TRACE_ID: 1534174322774-7edf2a7b
458----
459
460Given the trace ID an administrator can find the corresponding logs and
461investigate issues more easily.
462
Edwin Kempin77bbd8a2021-07-29 10:36:42 +0200463[[deadline]]
464==== Setting a deadline
465
466When pushing to Gerrit it's possible that the client sets a deadline after which
467the push should be aborted. To do this the `deadline=<deadline>` push option
468must be set on the git push. Values must be specified using standard time unit
469abbreviations ('ms', 'sec', 'min', etc.).
470
471----
472 git push -o deadline=10m ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master
473----
474
Edwin Kempin927ff822021-08-03 15:46:34 +0200475Setting a deadline for the push overrides any
476link:config-gerrit.html#deadline.id[server-side deadline] that has been
477configured on the host, but not the link:config.html#receive.timeout[receive
478timeout].
Edwin Kempin77bbd8a2021-07-29 10:36:42 +0200479
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700480[[push_replace]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800481=== Replace Changes
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700482
483To add an additional patch set to a change, ensure Change-Id
484lines were created in the original commit messages, and just use
485`git push URL HEAD:refs/for/...` as <<push_create,described above>>.
486Gerrit Code Review will automatically match the commits back to
487their original changes by taking advantage of the Change-Id lines.
488
489If Change-Id lines are not present in the commit messages, consider
490amending the message and copying the line from the change's page
491on the web, and then using `git push` as described above.
492
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700493For more about Change-Ids, see link:user-changeid.html[Change-Id Lines].
494
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800495
Edwin Kempin913eab12011-05-06 08:18:24 +0200496[[bypass_review]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800497=== Bypass Review
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800498
499Changes (and annotated tags) can be pushed directly into a
500repository, bypassing the review process. This is primarily useful
501for a project owner to create new branches, create annotated tags
502for releases, or to force-update a branch whose history needed to
503be rewritten.
504
505Gerrit restricts direct pushes that bypass review to:
506
Jonathan Nieder5758f182015-03-30 11:28:55 -0700507* `+refs/heads/*+`: any branch can be updated, created, deleted,
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800508or rewritten by the pusher.
Jonathan Nieder5758f182015-03-30 11:28:55 -0700509* `+refs/tags/*+`: annotated tag objects pointing to any other type
Nico Sallembien950e4152010-03-16 15:45:33 -0700510of Git object can be created.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800511
Fredrik Luthanderc10f9e72012-01-23 17:00:45 +0100512To push branches, the proper access rights must be configured first.
513Here follows a few examples of how to configure this in Gerrit:
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800514
515* Update: Any existing branch can be fast-forwarded to a new commit.
516This is the safest mode as commits cannot be discarded. Creation
Fredrik Luthanderc10f9e72012-01-23 17:00:45 +0100517of new branches is rejected. Can be configured with
518link:access-control.html#category_push_direct['Push'] access.
519* Create: Allows creation of a new branch if the name does not
520already designate an existing branch name. Needs
521link:access-control.html#category_create['Create Reference']
522configured. Please note that once created, this permission doesn't
523grant the right to update the branch with further commits (see above
524for update details).
525* Delete: Implies Update, but also allows an existing
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800526branch to be deleted. Since a force push is effectively a delete
527followed by a create, but performed atomically on the server and
528logged, this also permits forced push updates to branches.
Fredrik Luthanderc10f9e72012-01-23 17:00:45 +0100529To grant this access, configure
530link:access-control.html#category_push_direct['Push'] with the
531'Force' option ticked.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800532
Edwin Kempin62c15682016-09-05 14:32:38 +0200533To push annotated tags, the `Create Annotated Tag` project right must
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800534be granted to one (or more) of the user's groups. There is only
535one level of access in this category.
536
Edwin Kempin62c15682016-09-05 14:32:38 +0200537Project owners may wish to grant themselves `Create Annotated Tag`
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800538only at times when a new release is being prepared, and otherwise
539grant nothing at all. This ensures that accidental pushes don't
540make undesired changes to the public repository.
541
542
Dave Borowitzbf461402017-08-31 11:15:04 -0400543[[skip_validation]]
544=== Skip Validation
545
546Even when a user has permission to push directly to a branch
547link:#bypass_review[bypassing review], by default Gerrit will still validate any
548new commits, for example to check author/committer identities, and run
549link:config-validation.html#new-commit-validation[validation plugins]. This
550behavior can be bypassed with a push option:
551
552----
553git push -o skip-validation HEAD:master
554----
555
556Using the `skip-validation` option requires the user to have a specific set
557of permissions, *in addition* to those permissions already required to bypass
558review:
559
560* link:access-control.html#category_forge_author[Forge Author]
561* link:access-control.html#category_forge_committer[Forge Committer]
562* link:access-control.html#category_forge_server[Forge Server]
563* link:access-control.html#category_push_merge[Push Merge Commits]
564
565Plus these additional requirements on the project:
566
567* Project must not link:project-configuration.html#require-signed-off-by[require
568Signed-off-by].
569* Project must not have `refs/meta/reject-commits`.
570
571This option only applies when pushing directly to a branch bypassing review.
572Validation also occurs when pushing new changes for review, and that type of
573validation cannot be skipped.
574
Dave Borowitz78542192017-08-31 10:45:47 -0400575The `skip-validation` option is always required when pushing
576link:error-too-many-commits.html[more than a certain number of commits]. This is
577the recommended approach when pushing lots of old history, since some validators
578would require rewriting history in order to make them pass.
579
Dave Borowitzbf461402017-08-31 11:15:04 -0400580
Edwin Kempinbfa06212013-04-04 16:06:39 +0200581[[auto_merge]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800582=== Auto-Merge during Push
Edwin Kempinbfa06212013-04-04 16:06:39 +0200583
584Changes can be directly submitted on push. This is primarily useful
585for teams that don't want to do code review but want to use Gerrit's
586submit strategies to handle contention on busy branches. Using
Sebastian Schuberth8329b012016-03-15 14:48:33 +0100587`%submit` creates a change and submits it immediately:
Edwin Kempinbfa06212013-04-04 16:06:39 +0200588
Michael Ochmannb99feab2016-07-06 14:10:22 +0200589----
Edwin Kempinbfa06212013-04-04 16:06:39 +0200590 git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%submit
Michael Ochmannb99feab2016-07-06 14:10:22 +0200591----
Edwin Kempinbfa06212013-04-04 16:06:39 +0200592
593On auto-merge of a change neither labels nor submit rules are checked.
594If the merge fails the change stays open, but when pushing a new patch
595set the merge can be reattempted by using `%submit` again.
596
Sebastian Schuberth8329b012016-03-15 14:48:33 +0100597This requires the caller to have link:access-control.html#category_submit[Submit]
598permission on `refs/for/<ref>` (e.g. on `refs/for/refs/heads/master`).
599Note how this is different from the `Submit` permission on `refs/heads/<ref>`,
600and in particular you typically do not want to apply the `Submit` permission
601on `refs/*` (unless you are ok with bypassing submit rules).
Edwin Kempinbfa06212013-04-04 16:06:39 +0200602
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700603[[base]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800604=== Selecting Merge Base
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700605
606By default new changes are opened only for new unique commits
Patrick Hieseld883e072020-03-31 09:19:33 +0200607that are not part of any branch in refs/heads or the target
608branch. Clients may override that behavior and force new
609changes to be created by setting the merge base SHA-1 using
610the '%base' argument:
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700611
Michael Ochmannb99feab2016-07-06 14:10:22 +0200612----
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700613 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 +0200614----
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700615
Sasa Zivkovbc011a12013-11-07 16:08:31 +0100616It is also possible to specify more than one '%base' argument.
617This may be useful when pushing a merge commit. Note that the '%'
618character has only to be provided once, for the first '%base'
619argument:
620
Michael Ochmannb99feab2016-07-06 14:10:22 +0200621----
Sasa Zivkovbc011a12013-11-07 16:08:31 +0100622 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 +0200623----
Sasa Zivkovbc011a12013-11-07 16:08:31 +0100624
Dave Borowitza01219a2016-09-09 10:18:26 -0400625[[merged]]
626=== Creating Changes for Merged Commits
627
628Normally, changes are only created for commits that have not yet
629been merged into the branch. In some cases, you may want to review a
630change that has already been merged. A new change for a merged commit
631can be created by using the '%merged' argument:
632
633----
634 git push ssh://john.doe@git.example.com:29418/kernel/common my-merged-commit:refs/for/master%merged
635----
636
637This only creates one merged change at a time, corresponding to
638exactly `my-merged-commit`. It doesn't walk all of history up to that
639point, which could be slow and create lots of unintended new changes.
640To create multiple new changes, run push multiple times.
641
Gal Paikindd2e4f72021-06-17 13:14:11 +0200642[[ignore-attention-set]]
643=== Ignore automatic attention set rules
644
645Normally, we add users to the attention set based on several rules such as adding
646reviewers, replying, and many others. The full rule list is in
647link:user-attention-set.html[Attention Set].
648
649--ignore-automatic-attention-set-rules (also known as -ias and
650-ignore-attention-set) can be used to keep the attention set as it were before
651the push.
652
653----
654 git push ssh://john.doe@git.example.com:29418/kernel/common my-merged-commit:refs/for/master%ias
655----
Shawn Pearce5d8a2902013-04-22 11:50:23 -0700656
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800657== repo upload
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700658
659repo is a multiple repository management tool, most commonly
660used by the Android Open Source Project. For more details, see
Marian Harbach34253372019-12-10 18:01:31 +0100661link:http://source.android.com/source/using-repo.html[using repo,role=external,window=_blank].
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700662
663[[repo_create]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800664=== Create Changes
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700665
666To upload changes to a project using `repo`, ensure the manifest's
667review field has been configured to point to the Gerrit server.
668Only the hostname or the web address needs to be given in the
669manifest file. During upload `repo` will automatically determine the
670correct port number by reading `http://'reviewhostname'/ssh_info`
671when its invoked.
672
673Each new commit uploaded by `repo upload` will be converted into
674a change record on the server. Other users (e.g. project owners)
675who have configured Gerrit to notify them of new changes will be
676automatically sent an email message. Additional notifications can
677be sent through command line options.
678
679For more details on using `repo upload`, see `repo help upload`.
680
681[[repo_replace]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800682=== Replace Changes
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700683
684To replace changes, ensure Change-Id lines were created in the
Cecilia Svenssoncd2491d2012-01-20 14:22:30 +0100685commit messages, and just use `repo upload`.
686Gerrit Code Review will automatically match the commits back to
687their original changes by taking advantage of their Change-Id lines.
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700688
689If Change-Id lines are not present in the commit messages, consider
690amending the message and copying the line from the change's page
691on the web.
692
Shawn O. Pearce518fe3f2009-08-22 15:40:58 -0700693For more about Change-Ids, see link:user-changeid.html[Change-Id Lines].
694
695
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800696== Gritty Details
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800697
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800698As Gerrit implements the entire SSH and Git server stack within its
699own process space, Gerrit maintains complete control over how the
700repository is updated, and what responses are sent to the `git push`
701client invoked by the end-user, or by `repo upload`. This allows
Jonathan Nieder5758f182015-03-30 11:28:55 -0700702Gerrit to provide magical refs, such as `+refs/for/*+` for new
703change submission and `+refs/changes/*+` for change replacement.
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800704When a push request is received to create a ref in one of these
Dave Borowitzada289c2018-12-18 13:24:14 -0800705namespaces Gerrit performs its own logic to update the review metadata,
Shawn O. Pearcee61a3c62009-01-29 08:42:41 -0800706and then lies to the client about the result of the operation.
707A successful result causes the client to believe that Gerrit has
708created the ref, but in reality Gerrit hasn't created the ref at all.
709
710By implementing the entire server stack, Gerrit is also able to
711perform project level access control checks (to verify the end-user
712is permitted to access a project) prior to advertising the available
713refs, and potentially leaking information to a snooping client.
714Clients cannot tell the difference between 'project not found' and
715'project exists, but access is denied'.
716
717Gerrit can also ensure users have completed a valid Contributor
718Agreement prior to accepting any transferred objects, and if an
719agreement is required, but not completed, it aborts the network
720connection before data is sent. This ensures that project owners
721can be certain any object available in their repository has been
722supplied under at least one valid agreement.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700723
724GERRIT
725------
726Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700727
728SEARCHBOX
729---------