Marian Harbach | ebeb154 | 2019-12-13 10:42:46 +0100 | [diff] [blame] | 1 | :linkattrs: |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 2 | = Gerrit Code Review - Uploading Changes |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 3 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 4 | Gerrit supports three methods of uploading changes: |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 5 | |
| 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 Pursehouse | baac425 | 2013-01-25 17:42:19 +0900 | [diff] [blame] | 10 | All three methods rely on authentication, which must first be configured |
| 11 | by the uploading user. |
| 12 | |
Gert van Dijk | dc4f8d1 | 2017-08-27 21:14:23 +0200 | [diff] [blame] | 13 | Gerrit supports two protocols for uploading changes; SSH and HTTP/HTTPS. These |
| 14 | may not all be available for you, depending on the server configuration. |
David Pursehouse | baac425 | 2013-01-25 17:42:19 +0900 | [diff] [blame] | 15 | |
Edwin Kempin | 60ab853 | 2013-03-27 14:33:46 +0100 | [diff] [blame] | 16 | [[http]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 17 | == HTTP/HTTPS |
David Pursehouse | baac425 | 2013-01-25 17:42:19 +0900 | [diff] [blame] | 18 | |
| 19 | On Gerrit installations that do not support SSH authentication, the |
| 20 | user must authenticate via HTTP/HTTPS. |
| 21 | |
Han-Wen Nienhuys | 84d830b | 2017-02-15 16:36:04 +0100 | [diff] [blame] | 22 | The user is authenticated using standard BasicAuth. Depending on the |
| 23 | value of link:#auth.gitBasicAuthPolicy[auth.gitBasicAuthPolicy], |
| 24 | credentials are validated using: |
David Pursehouse | baac425 | 2013-01-25 17:42:19 +0900 | [diff] [blame] | 25 | |
Hector Oswaldo Caballero | 2a9ad1f | 2016-09-15 18:24:42 -0400 | [diff] [blame] | 26 | * 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 Milanesio | 1a91871 | 2021-05-06 20:20:48 +0100 | [diff] [blame] | 32 | When gitBasicAuthPolicy is set to `LDAP` or `HTTP_LDAP` and the user |
| 33 | is authenticating with the LDAP username/password, the Git client config |
| 34 | needs to have `http.cookieFile` set to a local file, otherwise every |
| 35 | single call would trigger a full LDAP authentication and groups resolution |
| 36 | which could introduce a noticeable latency on the overall execution |
| 37 | and produce unwanted load to the LDAP server. |
| 38 | |
Han-Wen Nienhuys | 84d830b | 2017-02-15 16:36:04 +0100 | [diff] [blame] | 39 | When gitBasicAuthPolicy is not `LDAP`, the user's HTTP credentials can |
| 40 | be regenerated by going to `Settings`, and then accessing the `HTTP |
| 41 | Password` tab. Revocation can effectively be done by regenerating the |
| 42 | password and then forgetting it. |
David Pursehouse | baac425 | 2013-01-25 17:42:19 +0900 | [diff] [blame] | 43 | |
| 44 | For Gerrit installations where an link:config-gerrit.html#auth.httpPasswordUrl[HTTP password URL] |
| 45 | is configured, the password can be obtained by clicking on `Obtain Password` |
| 46 | and then following the site-specific instructions. On sites where this URL is |
| 47 | not configured, the password can be obtained by clicking on `Generate Password`. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 48 | |
Edwin Kempin | 1f55622 | 2015-04-22 13:24:39 +0200 | [diff] [blame] | 49 | [[ssh]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 50 | == SSH |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 51 | |
Gert van Dijk | dc4f8d1 | 2017-08-27 21:14:23 +0200 | [diff] [blame] | 52 | To upload changes over SSH, Gerrit supports two forms of authentication: a |
| 53 | user's public key or kerberos. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 54 | |
Gert van Dijk | dc4f8d1 | 2017-08-27 21:14:23 +0200 | [diff] [blame] | 55 | Unless your Gerrit instance is configured to support |
| 56 | link:config-gerrit.html#sshd.kerberosKeytab[kerberos] in your domain, only |
| 57 | public key authentication can be used. |
| 58 | |
| 59 | [[configure_ssh_public_keys]] |
| 60 | === Public keys |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 61 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 62 | To register a new SSH key for use with Gerrit, paste the contents of |
| 63 | your `id_rsa.pub` or `id_dsa.pub` file into the text box and click |
| 64 | the add button. Gerrit only understands SSH version 2 public keys. |
| 65 | Keys 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. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 68 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 69 | Typically SSH keys are stored in your home directory, under `~/.ssh`. |
| 70 | If you don't have any keys yet, you can create a new one and protect |
| 71 | it with a passphrase: |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 72 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 73 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 74 | ssh-keygen -t rsa |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 75 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 76 | |
| 77 | Then copy the content of the public key file onto your clipboard, |
| 78 | and paste it into Gerrit's web interface: |
| 79 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 80 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 81 | cat ~/.ssh/id_rsa.pub |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 82 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 83 | |
| 84 | [TIP] |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 85 | Users who frequently upload changes will also want to consider |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 86 | starting an `ssh-agent`, and adding their private key to the list |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 87 | managed by the agent, to reduce the frequency of entering the |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 88 | key's passphrase. Consult `man ssh-agent`, or your SSH client's |
| 89 | documentation, for more details on configuration of the agent |
| 90 | process and how to add the private key. |
| 91 | |
Gert van Dijk | dc4f8d1 | 2017-08-27 21:14:23 +0200 | [diff] [blame] | 92 | [[configure_ssh_kerberos]] |
| 93 | === Kerberos |
| 94 | |
| 95 | A kerberos-enabled server configuration allows for zero configuration in an |
| 96 | existing single-sign-on environment. |
| 97 | |
| 98 | Your SSH client should be configured to enable kerberos authentication. For |
| 99 | OpenSSH clients, this is controlled by the option `GSSAPIAuthentication` which |
| 100 | should be set to `yes`. |
| 101 | |
| 102 | Some Linux distributions have packaged OpenSSH to enable this by default (e.g. |
| 103 | Debian, Ubuntu). If this is not the case for your distribution, enable it for |
| 104 | Gerrit with this entry in your local SSH configuration: |
| 105 | |
| 106 | ---- |
Gert van Dijk | 1415f07 | 2017-08-28 20:33:56 +0200 | [diff] [blame] | 107 | Host gerrit.mydomain.tld |
| 108 | GSSAPIAuthentication yes |
Gert van Dijk | dc4f8d1 | 2017-08-27 21:14:23 +0200 | [diff] [blame] | 109 | ---- |
| 110 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 111 | [[test_ssh]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 112 | === Testing Connections |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 113 | |
Gert van Dijk | dc4f8d1 | 2017-08-27 21:14:23 +0200 | [diff] [blame] | 114 | To verify your SSH authentication is working correctly, try using an SSH client |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 115 | to connect to Gerrit's SSHD port. By default Gerrit runs on |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 116 | port 29418, using the same hostname as the web server: |
| 117 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 118 | ---- |
Hugo Arès | 93ef427 | 2016-03-01 21:50:41 -0500 | [diff] [blame] | 119 | $ ssh -p 29418 sshusername@hostname |
Edwin Kempin | fb95a1b | 2011-10-05 10:08:00 +0200 | [diff] [blame] | 120 | |
| 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. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 130 | Connection to hostname closed. |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 131 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 132 | |
Edwin Kempin | fb95a1b | 2011-10-05 10:08:00 +0200 | [diff] [blame] | 133 | In the command above, `sshusername` was configured as `Username` on |
| 134 | the `Profile` tab of the `Settings` screen. If it is not set, |
| 135 | propose a name and use `Select Username` to select the name. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 136 | |
| 137 | To determine the port number Gerrit is running on, visit the special |
| 138 | information URL `http://'hostname'/ssh_info`, and copy the port |
| 139 | number from the second field: |
| 140 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 141 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 142 | $ curl http://hostname/ssh_info |
| 143 | hostname 29418 |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 144 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 145 | |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 146 | If you are developing an automated tool to perform uploads to Gerrit, |
| 147 | let the user supply the hostname or the web address for Gerrit, |
| 148 | and obtain the port number on the fly from the `/ssh_info` URL. |
| 149 | The returned output from this URL is always `'hostname' SP 'port'`, |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 150 | or `NOT_AVAILABLE` if the SSHD server is not currently running. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 151 | |
Gert van Dijk | 1415f07 | 2017-08-28 20:33:56 +0200 | [diff] [blame] | 152 | [[configure_ssh_host_entry]] |
| 153 | === OpenSSH Host entry |
| 154 | |
| 155 | If you are frequently uploading changes to the same Gerrit server, consider |
| 156 | adding an SSH `Host` entry in your OpenSSH client configuration |
| 157 | (`~/.ssh/config`) for that Gerrit server. It allows you use a single alias |
| 158 | defining your username, hostname and port number whenever you're accessing |
| 159 | this Gerrit server in an SSH context (also command line SSH or SCP). Use this |
| 160 | for 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. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 176 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 177 | == git push |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 178 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 179 | [[push_create]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 180 | === Create Changes |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 181 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 182 | To create new changes for review, simply push to the project's |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 183 | magical `refs/for/'branch'` ref using any Git client tool: |
| 184 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 185 | ---- |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 186 | git push ssh://sshusername@hostname:29418/projectname HEAD:refs/for/branch |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 187 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 188 | |
| 189 | E.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 Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 193 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 194 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 195 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 196 | |
| 197 | Each new commit uploaded by the `git push` client will be |
| 198 | converted into a change record on the server. The remote ref |
| 199 | `refs/for/experimental` is not actually created by Gerrit, even |
| 200 | though the client's status messages may say otherwise. |
| 201 | |
| 202 | Other users (e.g. project owners) who have configured Gerrit to |
| 203 | notify them of new changes will be automatically sent an email |
| 204 | message when the push is completed. |
| 205 | |
David Pursehouse | 06eb3eb | 2016-09-01 11:04:03 +0900 | [diff] [blame] | 206 | [[push_options]] |
| 207 | === Push Options |
| 208 | |
| 209 | Additional options may be specified when pushing changes. |
| 210 | |
Edwin Kempin | 9e078d8 | 2016-01-29 10:56:07 +0100 | [diff] [blame] | 211 | [[notify]] |
David Pursehouse | 06eb3eb | 2016-09-01 11:04:03 +0900 | [diff] [blame] | 212 | ==== Email Notifications |
Edwin Kempin | 9e078d8 | 2016-01-29 10:56:07 +0100 | [diff] [blame] | 213 | |
| 214 | Uploaders can control to whom email notifications are sent by setting |
| 215 | the `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 | |
| 227 | By default all email notifications are sent. |
| 228 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 229 | ---- |
Edwin Kempin | 9e078d8 | 2016-01-29 10:56:07 +0100 | [diff] [blame] | 230 | git push ssh://bot@git.example.com:29418/kernel/common HEAD:refs/for/master%notify=NONE |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 231 | ---- |
Edwin Kempin | 9e078d8 | 2016-01-29 10:56:07 +0100 | [diff] [blame] | 232 | |
Edwin Kempin | cd07df4 | 2016-12-01 09:10:09 +0100 | [diff] [blame] | 233 | In addition uploaders can explicitly specify accounts that should be |
| 234 | notified, regardless of the value that is given for the `notify` |
| 235 | option. To notify a specific account specify it by an |
| 236 | `notify-to='email'`, `notify-cc='email'` or `notify-bcc='email'` |
| 237 | option. These options can be specified as many times as necessary to |
| 238 | cover all interested parties. Gerrit will automatically avoid sending |
| 239 | duplicate email notifications, such as if one of the specified accounts |
| 240 | had also requested to receive all new change notifications. The |
| 241 | accounts that are specified by `notify-to='email'`, `notify-cc='email'` |
| 242 | and `notify-bcc='email'` will only be notified about this one push. |
| 243 | They are not added as link:#reviewers[reviewers or CCs], hence they are |
| 244 | not automatically signed up to be notified on further updates of the |
| 245 | change. |
| 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 Kempin | 1f55622 | 2015-04-22 13:24:39 +0200 | [diff] [blame] | 251 | [[topic]] |
David Pursehouse | 06eb3eb | 2016-09-01 11:04:03 +0900 | [diff] [blame] | 252 | ==== Topic |
| 253 | |
Dave Borowitz | 190cbd6 | 2018-03-15 10:35:59 -0400 | [diff] [blame] | 254 | To include a short link:intro-user.html#topics[topic] associated with all |
| 255 | of the changes in the same group, such as the local topic branch name, |
| 256 | append it after the destination branch name or add it with the command line |
| 257 | flag `--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. Pearce | d50c94e | 2010-07-15 12:24:11 -0700 | [diff] [blame] | 259 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 260 | ---- |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 261 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%topic=driver/i42 |
Dan Wang | 17ced40 | 2016-08-26 16:42:49 -0700 | [diff] [blame] | 262 | |
| 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 Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 265 | ---- |
Shawn O. Pearce | d50c94e | 2010-07-15 12:24:11 -0700 | [diff] [blame] | 266 | |
Dave Borowitz | 190cbd6 | 2018-03-15 10:35:59 -0400 | [diff] [blame] | 267 | [[hashtag]] |
| 268 | ==== Hashtag |
| 269 | |
| 270 | To include a link:intro-user.html#hashtags[hashtag] associated with all of the |
| 271 | changes 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 Kempin | 98ddc8a | 2017-02-21 11:56:08 +0100 | [diff] [blame] | 281 | [[private]] |
| 282 | ==== Private Changes |
| 283 | |
| 284 | To push a private change or to turn a change private on push the `private` |
| 285 | option can be specified: |
| 286 | |
| 287 | ---- |
| 288 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%private |
| 289 | ---- |
| 290 | |
| 291 | Omitting the `private` option when pushing updates to a private change |
| 292 | doesn't make change non-private again. To remove the private |
| 293 | flag 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 Ostrovsky | 98b27bd | 2017-04-02 15:25:20 +0200 | [diff] [blame] | 299 | [[wip]] |
| 300 | ==== Work-In-Progress Changes |
| 301 | |
| 302 | To push a wip change or to turn a change to wip the `work-in-progress` (or `wip`) |
| 303 | option can be specified: |
| 304 | |
| 305 | ---- |
| 306 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%wip |
| 307 | ---- |
| 308 | |
| 309 | Omitting the `wip` option when pushing updates to a wip change |
| 310 | doesn't make change ready again. To remove the `wip` |
| 311 | flag 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 Ostrovsky | 4424245 | 2018-06-09 20:25:13 +0200 | [diff] [blame] | 317 | Only change owners, project owners and site administrators can specify |
| 318 | `work-in-progress` and `ready` options on push. |
| 319 | |
David Ostrovsky | 821c532 | 2018-06-10 16:36:42 +0200 | [diff] [blame] | 320 | The default for this option can be set as a |
| 321 | link:intro-user.html#work-in-progress-by-default[user preference]. If the |
| 322 | preference is set so the default behavior is to create `work-in-progress` |
| 323 | changes, this can be overridden with the `ready` option. |
| 324 | |
Sven Selberg | f4435b0 | 2020-11-05 11:00:33 +0100 | [diff] [blame] | 325 | [[patch_set_description]] |
| 326 | ==== Patch Set Description |
David Pursehouse | 06eb3eb | 2016-09-01 11:04:03 +0900 | [diff] [blame] | 327 | |
Sven Selberg | f4435b0 | 2020-11-05 11:00:33 +0100 | [diff] [blame] | 328 | A link:concept-patch-sets.html#_description[patch set description] can be |
| 329 | applied by using the `message` (or `m`) option: |
Khai Do | 50eb94e | 2016-03-30 16:50:13 -0700 | [diff] [blame] | 330 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 331 | ---- |
Nick Carter | 83010b5 | 2017-10-30 12:54:42 -0700 | [diff] [blame] | 332 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%m=This_is_a_rebase_on_master%21 |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 333 | ---- |
Khai Do | 50eb94e | 2016-03-30 16:50:13 -0700 | [diff] [blame] | 334 | |
Michael Ochmann | 8129ece | 2016-07-08 11:25:25 +0200 | [diff] [blame] | 335 | [NOTE] |
Nick Carter | 83010b5 | 2017-10-30 12:54:42 -0700 | [diff] [blame] | 336 | git push refs parameter does not allow spaces. Use the '_' or '+' character |
| 337 | to represent spaces, and percent-encoding to represent other special chars. |
| 338 | The above example will thus be applied as "This is a rebase on master!" |
| 339 | |
| 340 | To avoid confusion in parsing the git ref, at least the following characters |
| 341 | must be percent-encoded: " %^@.~-+_:/!". Note that some of the reserved |
| 342 | characters (like tilde) are not escaped in the standard URL encoding rules, |
Mike Frysinger | 6336744 | 2022-05-20 05:37:40 -0400 | [diff] [blame] | 343 | so a language-provided function (e.g. encodeURIComponent(), in JavaScript) |
Nick Carter | 83010b5 | 2017-10-30 12:54:42 -0700 | [diff] [blame] | 344 | might not suffice. To be safest, you might consider percent-encoding all |
| 345 | non-alphanumeric characters (and all multibyte UTF-8 code points). |
Khai Do | 50eb94e | 2016-03-30 16:50:13 -0700 | [diff] [blame] | 346 | |
Dave Borowitz | cb86192 | 2017-04-27 06:12:02 -0400 | [diff] [blame] | 347 | [[publish-comments]] |
| 348 | ==== Publish Draft Comments |
| 349 | |
| 350 | If 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 Borowitz | d6ee48e | 2017-04-27 10:32:42 -0400 | [diff] [blame] | 357 | The default for this option can be set as a |
| 358 | link:intro-user.html#publish-comments-on-push[user preference]. If the |
| 359 | preference is set so the default behavior is to publish, this can be overridden |
| 360 | with the `no-publish-comments` (or `np`) option. |
| 361 | |
Gustaf Lundh | 4819171 | 2014-10-03 10:29:59 +0200 | [diff] [blame] | 362 | [[review_labels]] |
David Pursehouse | 06eb3eb | 2016-09-01 11:04:03 +0900 | [diff] [blame] | 363 | ==== Review Labels |
| 364 | |
David Pursehouse | 93733b6 | 2014-10-03 12:26:04 +0900 | [diff] [blame] | 365 | Review labels can be applied to the change by using the `label` (or `l`) |
| 366 | option in the reference: |
Gustaf Lundh | e235a06 | 2014-10-03 10:29:59 +0200 | [diff] [blame] | 367 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 368 | ---- |
Gustaf Lundh | e235a06 | 2014-10-03 10:29:59 +0200 | [diff] [blame] | 369 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%l=Verified+1 |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 370 | ---- |
Gustaf Lundh | e235a06 | 2014-10-03 10:29:59 +0200 | [diff] [blame] | 371 | |
| 372 | The `l='label[score]'` option may be specified more than once to |
| 373 | apply multiple review labels. |
| 374 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 375 | ---- |
Khai Do | 4bea1c6 | 2016-02-08 10:02:49 -0800 | [diff] [blame] | 376 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%l=Code-Review+1,l=Verified+1 |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 377 | ---- |
Khai Do | 4bea1c6 | 2016-02-08 10:02:49 -0800 | [diff] [blame] | 378 | |
Gustaf Lundh | e235a06 | 2014-10-03 10:29:59 +0200 | [diff] [blame] | 379 | The value is optional. If not specified, it defaults to +1 (if |
| 380 | the label range allows it). |
| 381 | |
David Ostrovsky | d07bb339 | 2015-01-19 07:43:44 +0100 | [diff] [blame] | 382 | [[change_edit]] |
David Pursehouse | 06eb3eb | 2016-09-01 11:04:03 +0900 | [diff] [blame] | 383 | ==== Change Edits |
| 384 | |
David Ostrovsky | d07bb339 | 2015-01-19 07:43:44 +0100 | [diff] [blame] | 385 | A change edit can be pushed by specifying the `edit` (or `e`) option on |
| 386 | the reference: |
| 387 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 388 | ---- |
David Ostrovsky | d07bb339 | 2015-01-19 07:43:44 +0100 | [diff] [blame] | 389 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%edit |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 390 | ---- |
David Ostrovsky | d07bb339 | 2015-01-19 07:43:44 +0100 | [diff] [blame] | 391 | |
| 392 | There is at most one change edit per user and change. In order to push |
| 393 | a change edit the change must already exist. |
| 394 | |
| 395 | [NOTE] |
| 396 | When a change edit already exists for a change then pushing with |
| 397 | `%edit` replaces the existing change edit. This option is useful to |
| 398 | rebase a change edit on the newest patch set when the rebase of the |
| 399 | change edit in the web UI fails due to conflicts. |
| 400 | |
David Pursehouse | 06eb3eb | 2016-09-01 11:04:03 +0900 | [diff] [blame] | 401 | [[reviewers]] |
| 402 | ==== Reviewers |
| 403 | |
Edwin Kempin | b5df3b8 | 2011-10-10 11:31:14 +0200 | [diff] [blame] | 404 | Specific reviewers can be requested and/or additional 'carbon |
David Pursehouse | 93733b6 | 2014-10-03 12:26:04 +0900 | [diff] [blame] | 405 | copies' of the notification message may be sent by including the |
| 406 | `reviewer` (or `r`) and `cc` options in the reference: |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 407 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 408 | ---- |
Gert van Dijk | 1415f07 | 2017-08-28 20:33:56 +0200 | [diff] [blame] | 409 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%r=a@a.com,cc=b@o.com |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 410 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 411 | |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 412 | The `r='email'` and `cc='email'` options may be specified as many |
| 413 | times as necessary to cover all interested parties. Gerrit will |
| 414 | automatically avoid sending duplicate email notifications, such as |
| 415 | if one of the specified reviewers or CC addresses had also requested |
| 416 | to receive all new change notifications. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 417 | |
| 418 | If you are frequently sending changes to the same parties and/or |
| 419 | branches, consider adding a custom remote block to your project's |
| 420 | `.git/config` file: |
| 421 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 422 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 423 | $ cat .git/config |
| 424 | ... |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 425 | [remote "exp"] |
Gert van Dijk | 1415f07 | 2017-08-28 20:33:56 +0200 | [diff] [blame] | 426 | url = ssh://john.doe@git.example.com:29418/kernel/common |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 427 | push = HEAD:refs/for/experimental%r=a@a.com,cc=b@o.com |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 428 | |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 429 | $ git push exp |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 430 | ---- |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 431 | |
Edwin Kempin | 0ade5aa | 2018-08-10 08:49:32 +0200 | [diff] [blame] | 432 | [[trace]] |
| 433 | ==== Trace |
| 434 | |
Edwin Kempin | da82378 | 2018-08-29 22:52:54 +0200 | [diff] [blame] | 435 | When 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 |
| 437 | issue that is being investigated as trace ID. |
Edwin Kempin | 0ade5aa | 2018-08-10 08:49:32 +0200 | [diff] [blame] | 438 | |
| 439 | ---- |
Edwin Kempin | da82378 | 2018-08-29 22:52:54 +0200 | [diff] [blame] | 440 | git push -o trace=issue/123 ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master |
| 441 | ---- |
| 442 | |
| 443 | It is also possible to omit the trace ID and get a unique trace ID |
| 444 | generated. |
| 445 | |
| 446 | .Example Request |
| 447 | ---- |
Edwin Kempin | 8b7376b | 2018-08-29 08:38:30 +0200 | [diff] [blame] | 448 | git push -o trace ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master |
Edwin Kempin | 0ade5aa | 2018-08-10 08:49:32 +0200 | [diff] [blame] | 449 | ---- |
| 450 | |
| 451 | Enabling tracing results in additional logs with debug information that |
| 452 | are written to the `error_log`. All logs that correspond to the traced |
Edwin Kempin | da82378 | 2018-08-29 22:52:54 +0200 | [diff] [blame] | 453 | request are associated with the trace ID. This trace ID is returned in |
| 454 | the command output: |
Edwin Kempin | 0ade5aa | 2018-08-10 08:49:32 +0200 | [diff] [blame] | 455 | |
| 456 | ---- |
| 457 | remote: TRACE_ID: 1534174322774-7edf2a7b |
| 458 | ---- |
| 459 | |
| 460 | Given the trace ID an administrator can find the corresponding logs and |
| 461 | investigate issues more easily. |
| 462 | |
Edwin Kempin | 77bbd8a | 2021-07-29 10:36:42 +0200 | [diff] [blame] | 463 | [[deadline]] |
| 464 | ==== Setting a deadline |
| 465 | |
| 466 | When pushing to Gerrit it's possible that the client sets a deadline after which |
| 467 | the push should be aborted. To do this the `deadline=<deadline>` push option |
| 468 | must be set on the git push. Values must be specified using standard time unit |
| 469 | abbreviations ('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 Kempin | 927ff82 | 2021-08-03 15:46:34 +0200 | [diff] [blame] | 475 | Setting a deadline for the push overrides any |
| 476 | link:config-gerrit.html#deadline.id[server-side deadline] that has been |
| 477 | configured on the host, but not the link:config.html#receive.timeout[receive |
| 478 | timeout]. |
Edwin Kempin | 77bbd8a | 2021-07-29 10:36:42 +0200 | [diff] [blame] | 479 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 480 | [[push_replace]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 481 | === Replace Changes |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 482 | |
| 483 | To add an additional patch set to a change, ensure Change-Id |
| 484 | lines were created in the original commit messages, and just use |
| 485 | `git push URL HEAD:refs/for/...` as <<push_create,described above>>. |
| 486 | Gerrit Code Review will automatically match the commits back to |
| 487 | their original changes by taking advantage of the Change-Id lines. |
| 488 | |
| 489 | If Change-Id lines are not present in the commit messages, consider |
| 490 | amending the message and copying the line from the change's page |
| 491 | on the web, and then using `git push` as described above. |
| 492 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 493 | For more about Change-Ids, see link:user-changeid.html[Change-Id Lines]. |
| 494 | |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 495 | |
Edwin Kempin | 913eab1 | 2011-05-06 08:18:24 +0200 | [diff] [blame] | 496 | [[bypass_review]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 497 | === Bypass Review |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 498 | |
| 499 | Changes (and annotated tags) can be pushed directly into a |
| 500 | repository, bypassing the review process. This is primarily useful |
| 501 | for a project owner to create new branches, create annotated tags |
| 502 | for releases, or to force-update a branch whose history needed to |
| 503 | be rewritten. |
| 504 | |
| 505 | Gerrit restricts direct pushes that bypass review to: |
| 506 | |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 507 | * `+refs/heads/*+`: any branch can be updated, created, deleted, |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 508 | or rewritten by the pusher. |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 509 | * `+refs/tags/*+`: annotated tag objects pointing to any other type |
Nico Sallembien | 950e415 | 2010-03-16 15:45:33 -0700 | [diff] [blame] | 510 | of Git object can be created. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 511 | |
Fredrik Luthander | c10f9e7 | 2012-01-23 17:00:45 +0100 | [diff] [blame] | 512 | To push branches, the proper access rights must be configured first. |
| 513 | Here follows a few examples of how to configure this in Gerrit: |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 514 | |
| 515 | * Update: Any existing branch can be fast-forwarded to a new commit. |
| 516 | This is the safest mode as commits cannot be discarded. Creation |
Fredrik Luthander | c10f9e7 | 2012-01-23 17:00:45 +0100 | [diff] [blame] | 517 | of new branches is rejected. Can be configured with |
| 518 | link:access-control.html#category_push_direct['Push'] access. |
| 519 | * Create: Allows creation of a new branch if the name does not |
| 520 | already designate an existing branch name. Needs |
| 521 | link:access-control.html#category_create['Create Reference'] |
| 522 | configured. Please note that once created, this permission doesn't |
| 523 | grant the right to update the branch with further commits (see above |
| 524 | for update details). |
| 525 | * Delete: Implies Update, but also allows an existing |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 526 | branch to be deleted. Since a force push is effectively a delete |
| 527 | followed by a create, but performed atomically on the server and |
| 528 | logged, this also permits forced push updates to branches. |
Fredrik Luthander | c10f9e7 | 2012-01-23 17:00:45 +0100 | [diff] [blame] | 529 | To grant this access, configure |
| 530 | link:access-control.html#category_push_direct['Push'] with the |
| 531 | 'Force' option ticked. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 532 | |
Edwin Kempin | 62c1568 | 2016-09-05 14:32:38 +0200 | [diff] [blame] | 533 | To push annotated tags, the `Create Annotated Tag` project right must |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 534 | be granted to one (or more) of the user's groups. There is only |
| 535 | one level of access in this category. |
| 536 | |
Edwin Kempin | 62c1568 | 2016-09-05 14:32:38 +0200 | [diff] [blame] | 537 | Project owners may wish to grant themselves `Create Annotated Tag` |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 538 | only at times when a new release is being prepared, and otherwise |
| 539 | grant nothing at all. This ensures that accidental pushes don't |
| 540 | make undesired changes to the public repository. |
| 541 | |
| 542 | |
Dave Borowitz | bf46140 | 2017-08-31 11:15:04 -0400 | [diff] [blame] | 543 | [[skip_validation]] |
| 544 | === Skip Validation |
| 545 | |
| 546 | Even when a user has permission to push directly to a branch |
| 547 | link:#bypass_review[bypassing review], by default Gerrit will still validate any |
| 548 | new commits, for example to check author/committer identities, and run |
| 549 | link:config-validation.html#new-commit-validation[validation plugins]. This |
| 550 | behavior can be bypassed with a push option: |
| 551 | |
| 552 | ---- |
| 553 | git push -o skip-validation HEAD:master |
| 554 | ---- |
| 555 | |
| 556 | Using the `skip-validation` option requires the user to have a specific set |
| 557 | of permissions, *in addition* to those permissions already required to bypass |
| 558 | review: |
| 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 | |
| 565 | Plus these additional requirements on the project: |
| 566 | |
| 567 | * Project must not link:project-configuration.html#require-signed-off-by[require |
| 568 | Signed-off-by]. |
| 569 | * Project must not have `refs/meta/reject-commits`. |
| 570 | |
| 571 | This option only applies when pushing directly to a branch bypassing review. |
| 572 | Validation also occurs when pushing new changes for review, and that type of |
| 573 | validation cannot be skipped. |
| 574 | |
Dave Borowitz | 7854219 | 2017-08-31 10:45:47 -0400 | [diff] [blame] | 575 | The `skip-validation` option is always required when pushing |
| 576 | link:error-too-many-commits.html[more than a certain number of commits]. This is |
| 577 | the recommended approach when pushing lots of old history, since some validators |
| 578 | would require rewriting history in order to make them pass. |
| 579 | |
Dave Borowitz | bf46140 | 2017-08-31 11:15:04 -0400 | [diff] [blame] | 580 | |
Edwin Kempin | bfa0621 | 2013-04-04 16:06:39 +0200 | [diff] [blame] | 581 | [[auto_merge]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 582 | === Auto-Merge during Push |
Edwin Kempin | bfa0621 | 2013-04-04 16:06:39 +0200 | [diff] [blame] | 583 | |
| 584 | Changes can be directly submitted on push. This is primarily useful |
| 585 | for teams that don't want to do code review but want to use Gerrit's |
| 586 | submit strategies to handle contention on busy branches. Using |
Sebastian Schuberth | 8329b01 | 2016-03-15 14:48:33 +0100 | [diff] [blame] | 587 | `%submit` creates a change and submits it immediately: |
Edwin Kempin | bfa0621 | 2013-04-04 16:06:39 +0200 | [diff] [blame] | 588 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 589 | ---- |
Edwin Kempin | bfa0621 | 2013-04-04 16:06:39 +0200 | [diff] [blame] | 590 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%submit |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 591 | ---- |
Edwin Kempin | bfa0621 | 2013-04-04 16:06:39 +0200 | [diff] [blame] | 592 | |
| 593 | On auto-merge of a change neither labels nor submit rules are checked. |
| 594 | If the merge fails the change stays open, but when pushing a new patch |
| 595 | set the merge can be reattempted by using `%submit` again. |
| 596 | |
Sebastian Schuberth | 8329b01 | 2016-03-15 14:48:33 +0100 | [diff] [blame] | 597 | This requires the caller to have link:access-control.html#category_submit[Submit] |
| 598 | permission on `refs/for/<ref>` (e.g. on `refs/for/refs/heads/master`). |
| 599 | Note how this is different from the `Submit` permission on `refs/heads/<ref>`, |
| 600 | and in particular you typically do not want to apply the `Submit` permission |
| 601 | on `refs/*` (unless you are ok with bypassing submit rules). |
Edwin Kempin | bfa0621 | 2013-04-04 16:06:39 +0200 | [diff] [blame] | 602 | |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 603 | [[base]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 604 | === Selecting Merge Base |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 605 | |
| 606 | By default new changes are opened only for new unique commits |
Patrick Hiesel | d883e07 | 2020-03-31 09:19:33 +0200 | [diff] [blame] | 607 | that are not part of any branch in refs/heads or the target |
| 608 | branch. Clients may override that behavior and force new |
| 609 | changes to be created by setting the merge base SHA-1 using |
| 610 | the '%base' argument: |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 611 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 612 | ---- |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 613 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=$(git rev-parse origin/master) |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 614 | ---- |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 615 | |
Sasa Zivkov | bc011a1 | 2013-11-07 16:08:31 +0100 | [diff] [blame] | 616 | It is also possible to specify more than one '%base' argument. |
| 617 | This may be useful when pushing a merge commit. Note that the '%' |
| 618 | character has only to be provided once, for the first '%base' |
| 619 | argument: |
| 620 | |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 621 | ---- |
Sasa Zivkov | bc011a1 | 2013-11-07 16:08:31 +0100 | [diff] [blame] | 622 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=commit-id1,base=commit-id2 |
Michael Ochmann | b99feab | 2016-07-06 14:10:22 +0200 | [diff] [blame] | 623 | ---- |
Sasa Zivkov | bc011a1 | 2013-11-07 16:08:31 +0100 | [diff] [blame] | 624 | |
Dave Borowitz | a01219a | 2016-09-09 10:18:26 -0400 | [diff] [blame] | 625 | [[merged]] |
| 626 | === Creating Changes for Merged Commits |
| 627 | |
| 628 | Normally, changes are only created for commits that have not yet |
| 629 | been merged into the branch. In some cases, you may want to review a |
| 630 | change that has already been merged. A new change for a merged commit |
| 631 | can 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 | |
| 637 | This only creates one merged change at a time, corresponding to |
| 638 | exactly `my-merged-commit`. It doesn't walk all of history up to that |
| 639 | point, which could be slow and create lots of unintended new changes. |
| 640 | To create multiple new changes, run push multiple times. |
| 641 | |
Gal Paikin | dd2e4f7 | 2021-06-17 13:14:11 +0200 | [diff] [blame] | 642 | [[ignore-attention-set]] |
| 643 | === Ignore automatic attention set rules |
| 644 | |
| 645 | Normally, we add users to the attention set based on several rules such as adding |
| 646 | reviewers, replying, and many others. The full rule list is in |
| 647 | link: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 |
| 651 | the push. |
| 652 | |
| 653 | ---- |
| 654 | git push ssh://john.doe@git.example.com:29418/kernel/common my-merged-commit:refs/for/master%ias |
| 655 | ---- |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 656 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 657 | == repo upload |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 658 | |
| 659 | repo is a multiple repository management tool, most commonly |
| 660 | used by the Android Open Source Project. For more details, see |
Marian Harbach | 3425337 | 2019-12-10 18:01:31 +0100 | [diff] [blame] | 661 | link:http://source.android.com/source/using-repo.html[using repo,role=external,window=_blank]. |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 662 | |
| 663 | [[repo_create]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 664 | === Create Changes |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 665 | |
| 666 | To upload changes to a project using `repo`, ensure the manifest's |
| 667 | review field has been configured to point to the Gerrit server. |
| 668 | Only the hostname or the web address needs to be given in the |
| 669 | manifest file. During upload `repo` will automatically determine the |
| 670 | correct port number by reading `http://'reviewhostname'/ssh_info` |
| 671 | when its invoked. |
| 672 | |
| 673 | Each new commit uploaded by `repo upload` will be converted into |
| 674 | a change record on the server. Other users (e.g. project owners) |
| 675 | who have configured Gerrit to notify them of new changes will be |
| 676 | automatically sent an email message. Additional notifications can |
| 677 | be sent through command line options. |
| 678 | |
| 679 | For more details on using `repo upload`, see `repo help upload`. |
| 680 | |
| 681 | [[repo_replace]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 682 | === Replace Changes |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 683 | |
| 684 | To replace changes, ensure Change-Id lines were created in the |
Cecilia Svensson | cd2491d | 2012-01-20 14:22:30 +0100 | [diff] [blame] | 685 | commit messages, and just use `repo upload`. |
| 686 | Gerrit Code Review will automatically match the commits back to |
| 687 | their original changes by taking advantage of their Change-Id lines. |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 688 | |
| 689 | If Change-Id lines are not present in the commit messages, consider |
| 690 | amending the message and copying the line from the change's page |
| 691 | on the web. |
| 692 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 693 | For more about Change-Ids, see link:user-changeid.html[Change-Id Lines]. |
| 694 | |
| 695 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 696 | == Gritty Details |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 697 | |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 698 | As Gerrit implements the entire SSH and Git server stack within its |
| 699 | own process space, Gerrit maintains complete control over how the |
| 700 | repository is updated, and what responses are sent to the `git push` |
| 701 | client invoked by the end-user, or by `repo upload`. This allows |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 702 | Gerrit to provide magical refs, such as `+refs/for/*+` for new |
| 703 | change submission and `+refs/changes/*+` for change replacement. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 704 | When a push request is received to create a ref in one of these |
Dave Borowitz | ada289c | 2018-12-18 13:24:14 -0800 | [diff] [blame] | 705 | namespaces Gerrit performs its own logic to update the review metadata, |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 706 | and then lies to the client about the result of the operation. |
| 707 | A successful result causes the client to believe that Gerrit has |
| 708 | created the ref, but in reality Gerrit hasn't created the ref at all. |
| 709 | |
| 710 | By implementing the entire server stack, Gerrit is also able to |
| 711 | perform project level access control checks (to verify the end-user |
| 712 | is permitted to access a project) prior to advertising the available |
| 713 | refs, and potentially leaking information to a snooping client. |
| 714 | Clients cannot tell the difference between 'project not found' and |
| 715 | 'project exists, but access is denied'. |
| 716 | |
| 717 | Gerrit can also ensure users have completed a valid Contributor |
| 718 | Agreement prior to accepting any transferred objects, and if an |
| 719 | agreement is required, but not completed, it aborts the network |
| 720 | connection before data is sent. This ensures that project owners |
| 721 | can be certain any object available in their repository has been |
| 722 | supplied under at least one valid agreement. |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 723 | |
| 724 | GERRIT |
| 725 | ------ |
| 726 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 727 | |
| 728 | SEARCHBOX |
| 729 | --------- |