Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Uploading Changes |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 2 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 3 | Gerrit supports three methods of uploading changes: |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 4 | |
| 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 Pursehouse | baac425 | 2013-01-25 17:42:19 +0900 | [diff] [blame] | 9 | All three methods rely on authentication, which must first be configured |
| 10 | by the uploading user. |
| 11 | |
| 12 | Gerrit supports two methods of authenticating the uploading user. SSH |
| 13 | public key, and HTTP/HTTPS. |
| 14 | |
Edwin Kempin | 60ab853 | 2013-03-27 14:33:46 +0100 | [diff] [blame] | 15 | [[http]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 16 | == HTTP/HTTPS |
David Pursehouse | baac425 | 2013-01-25 17:42:19 +0900 | [diff] [blame] | 17 | |
| 18 | On Gerrit installations that do not support SSH authentication, the |
| 19 | user must authenticate via HTTP/HTTPS. |
| 20 | |
| 21 | When link:config-gerrit.html#auth.gitBasicAuth[gitBasicAuth] is enabled, |
| 22 | the user is authenticated using standard BasicAuth and credentials validated |
Luca Milanesio | b281cd4 | 2014-03-05 23:46:26 +0000 | [diff] [blame] | 23 | using the randomly generated HTTP password on the `HTTP Password` tab |
| 24 | in the user settings page or against LDAP when configured for the Gerrit Web UI. |
David Pursehouse | baac425 | 2013-01-25 17:42:19 +0900 | [diff] [blame] | 25 | |
| 26 | When gitBasicAuth is not configured, the user's HTTP credentials can be |
| 27 | accessed within Gerrit by going to `Settings`, and then accessing the `HTTP |
| 28 | Password` tab. |
| 29 | |
| 30 | For Gerrit installations where an link:config-gerrit.html#auth.httpPasswordUrl[HTTP password URL] |
| 31 | is configured, the password can be obtained by clicking on `Obtain Password` |
| 32 | and then following the site-specific instructions. On sites where this URL is |
| 33 | 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] | 34 | |
Edwin Kempin | 1f55622 | 2015-04-22 13:24:39 +0200 | [diff] [blame] | 35 | [[ssh]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 36 | == SSH |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 37 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 38 | Each user uploading changes to Gerrit must configure one or more SSH |
| 39 | public keys. The per-user SSH key list can be accessed over the web |
Edwin Kempin | b5df3b8 | 2011-10-10 11:31:14 +0200 | [diff] [blame] | 40 | within Gerrit by `Settings`, and then accessing the `SSH Public Keys` |
| 41 | tab. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 42 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 43 | [[configure_ssh]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 44 | === Configuration |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 45 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 46 | To register a new SSH key for use with Gerrit, paste the contents of |
| 47 | your `id_rsa.pub` or `id_dsa.pub` file into the text box and click |
| 48 | the add button. Gerrit only understands SSH version 2 public keys. |
| 49 | Keys may be supplied in either the OpenSSH format (key starts with |
| 50 | `ssh-rsa` or `ssh-dss`) or the RFC 4716 format (file starts with |
| 51 | `---- BEGIN SSH2 PUBLIC KEY ----`). |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 52 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 53 | Typically SSH keys are stored in your home directory, under `~/.ssh`. |
| 54 | If you don't have any keys yet, you can create a new one and protect |
| 55 | it with a passphrase: |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 56 | |
| 57 | ==== |
| 58 | ssh-keygen -t rsa |
| 59 | ==== |
| 60 | |
| 61 | Then copy the content of the public key file onto your clipboard, |
| 62 | and paste it into Gerrit's web interface: |
| 63 | |
| 64 | ==== |
| 65 | cat ~/.ssh/id_rsa.pub |
| 66 | ==== |
| 67 | |
| 68 | [TIP] |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 69 | Users who frequently upload changes will also want to consider |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 70 | 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] | 71 | managed by the agent, to reduce the frequency of entering the |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 72 | key's passphrase. Consult `man ssh-agent`, or your SSH client's |
| 73 | documentation, for more details on configuration of the agent |
| 74 | process and how to add the private key. |
| 75 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 76 | [[test_ssh]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 77 | === Testing Connections |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 78 | |
| 79 | To verify your SSH key is working correctly, try using an SSH client |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 80 | 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] | 81 | port 29418, using the same hostname as the web server: |
| 82 | |
| 83 | ==== |
Edwin Kempin | fb95a1b | 2011-10-05 10:08:00 +0200 | [diff] [blame] | 84 | .................................................................. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 85 | $ ssh -p 29418 sshusername@hostname |
Edwin Kempin | fb95a1b | 2011-10-05 10:08:00 +0200 | [diff] [blame] | 86 | |
| 87 | **** Welcome to Gerrit Code Review **** |
| 88 | |
| 89 | Hi John Doe, you have successfully connected over SSH. |
| 90 | |
| 91 | Unfortunately, interactive shells are disabled. |
| 92 | To clone a hosted Git repository, use: |
| 93 | |
| 94 | git clone ssh://sshusername@hostname:29418/REPOSITORY_NAME.git |
| 95 | |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 96 | Connection to hostname closed. |
Edwin Kempin | fb95a1b | 2011-10-05 10:08:00 +0200 | [diff] [blame] | 97 | .................................................................. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 98 | ==== |
| 99 | |
Edwin Kempin | fb95a1b | 2011-10-05 10:08:00 +0200 | [diff] [blame] | 100 | In the command above, `sshusername` was configured as `Username` on |
| 101 | the `Profile` tab of the `Settings` screen. If it is not set, |
| 102 | propose a name and use `Select Username` to select the name. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 103 | |
| 104 | To determine the port number Gerrit is running on, visit the special |
| 105 | information URL `http://'hostname'/ssh_info`, and copy the port |
| 106 | number from the second field: |
| 107 | |
| 108 | ==== |
| 109 | $ curl http://hostname/ssh_info |
| 110 | hostname 29418 |
| 111 | ==== |
| 112 | |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 113 | If you are developing an automated tool to perform uploads to Gerrit, |
| 114 | let the user supply the hostname or the web address for Gerrit, |
| 115 | and obtain the port number on the fly from the `/ssh_info` URL. |
| 116 | The returned output from this URL is always `'hostname' SP 'port'`, |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 117 | or `NOT_AVAILABLE` if the SSHD server is not currently running. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 118 | |
| 119 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 120 | == git push |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 121 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 122 | [[push_create]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 123 | === Create Changes |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 124 | |
David Pursehouse | 221d4f6 | 2012-06-08 17:38:08 +0900 | [diff] [blame] | 125 | 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] | 126 | magical `refs/for/'branch'` ref using any Git client tool: |
| 127 | |
| 128 | ==== |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 129 | git push ssh://sshusername@hostname:29418/projectname HEAD:refs/for/branch |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 130 | ==== |
| 131 | |
| 132 | E.g. `john.doe` can use git push to upload new changes for the |
| 133 | `experimental` branch of project `kernel/common`, hosted at the |
| 134 | `git.example.com` Gerrit server: |
| 135 | |
| 136 | ==== |
| 137 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental |
| 138 | ==== |
| 139 | |
| 140 | Each new commit uploaded by the `git push` client will be |
| 141 | converted into a change record on the server. The remote ref |
| 142 | `refs/for/experimental` is not actually created by Gerrit, even |
| 143 | though the client's status messages may say otherwise. |
| 144 | |
| 145 | Other users (e.g. project owners) who have configured Gerrit to |
| 146 | notify them of new changes will be automatically sent an email |
| 147 | message when the push is completed. |
| 148 | |
Edwin Kempin | 1f55622 | 2015-04-22 13:24:39 +0200 | [diff] [blame] | 149 | [[topic]] |
Shawn O. Pearce | d50c94e | 2010-07-15 12:24:11 -0700 | [diff] [blame] | 150 | To include a short tag associated with all of the changes in the |
| 151 | same group, such as the local topic branch name, append it after |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 152 | the destination branch name. In this example the short topic tag |
Shawn O. Pearce | d50c94e | 2010-07-15 12:24:11 -0700 | [diff] [blame] | 153 | 'driver/i42' will be saved on each change this push creates or |
| 154 | updates: |
| 155 | |
| 156 | ==== |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 157 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%topic=driver/i42 |
Shawn O. Pearce | d50c94e | 2010-07-15 12:24:11 -0700 | [diff] [blame] | 158 | ==== |
| 159 | |
Gustaf Lundh | 4819171 | 2014-10-03 10:29:59 +0200 | [diff] [blame] | 160 | [[review_labels]] |
David Pursehouse | 93733b6 | 2014-10-03 12:26:04 +0900 | [diff] [blame] | 161 | Review labels can be applied to the change by using the `label` (or `l`) |
| 162 | option in the reference: |
Gustaf Lundh | e235a06 | 2014-10-03 10:29:59 +0200 | [diff] [blame] | 163 | |
| 164 | ==== |
| 165 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/experimental%l=Verified+1 |
| 166 | ==== |
| 167 | |
| 168 | The `l='label[score]'` option may be specified more than once to |
| 169 | apply multiple review labels. |
| 170 | |
| 171 | The value is optional. If not specified, it defaults to +1 (if |
| 172 | the label range allows it). |
| 173 | |
David Ostrovsky | d07bb339 | 2015-01-19 07:43:44 +0100 | [diff] [blame] | 174 | [[change_edit]] |
| 175 | A change edit can be pushed by specifying the `edit` (or `e`) option on |
| 176 | the reference: |
| 177 | |
| 178 | ==== |
| 179 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%edit |
| 180 | ==== |
| 181 | |
| 182 | There is at most one change edit per user and change. In order to push |
| 183 | a change edit the change must already exist. |
| 184 | |
| 185 | [NOTE] |
| 186 | When a change edit already exists for a change then pushing with |
| 187 | `%edit` replaces the existing change edit. This option is useful to |
| 188 | rebase a change edit on the newest patch set when the rebase of the |
| 189 | change edit in the web UI fails due to conflicts. |
| 190 | |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 191 | If you are frequently uploading changes to the same Gerrit server, |
| 192 | consider adding an SSH host block in `~/.ssh/config` to remember |
| 193 | your username, hostname and port number. This permits the use of |
| 194 | shorter URLs on the command line, such as: |
| 195 | |
| 196 | ==== |
| 197 | $ cat ~/.ssh/config |
| 198 | ... |
| 199 | Host tr |
| 200 | Hostname git.example.com |
| 201 | Port 29418 |
| 202 | User john.doe |
| 203 | |
| 204 | $ git push tr:kernel/common HEAD:refs/for/experimental |
| 205 | ==== |
| 206 | |
Edwin Kempin | b5df3b8 | 2011-10-10 11:31:14 +0200 | [diff] [blame] | 207 | Specific reviewers can be requested and/or additional 'carbon |
David Pursehouse | 93733b6 | 2014-10-03 12:26:04 +0900 | [diff] [blame] | 208 | copies' of the notification message may be sent by including the |
| 209 | `reviewer` (or `r`) and `cc` options in the reference: |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 210 | |
| 211 | ==== |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 212 | git push tr:kernel/common 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] | 213 | ==== |
| 214 | |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 215 | The `r='email'` and `cc='email'` options may be specified as many |
| 216 | times as necessary to cover all interested parties. Gerrit will |
| 217 | automatically avoid sending duplicate email notifications, such as |
| 218 | if one of the specified reviewers or CC addresses had also requested |
| 219 | to receive all new change notifications. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 220 | |
| 221 | If you are frequently sending changes to the same parties and/or |
| 222 | branches, consider adding a custom remote block to your project's |
| 223 | `.git/config` file: |
| 224 | |
| 225 | ==== |
| 226 | $ cat .git/config |
| 227 | ... |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 228 | [remote "exp"] |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 229 | url = tr:kernel/common |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 230 | 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] | 231 | |
Shawn Pearce | 69928a6 | 2013-02-24 18:01:27 -0800 | [diff] [blame] | 232 | $ git push exp |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 233 | ==== |
| 234 | |
| 235 | |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 236 | [[push_replace]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 237 | === Replace Changes |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 238 | |
| 239 | To add an additional patch set to a change, ensure Change-Id |
| 240 | lines were created in the original commit messages, and just use |
| 241 | `git push URL HEAD:refs/for/...` as <<push_create,described above>>. |
| 242 | Gerrit Code Review will automatically match the commits back to |
| 243 | their original changes by taking advantage of the Change-Id lines. |
| 244 | |
| 245 | If Change-Id lines are not present in the commit messages, consider |
| 246 | amending the message and copying the line from the change's page |
| 247 | on the web, and then using `git push` as described above. |
| 248 | |
| 249 | If Change-Id lines are not available, then the user must use the |
| 250 | manual mapping technique described below. |
| 251 | |
| 252 | For more about Change-Ids, see link:user-changeid.html[Change-Id Lines]. |
| 253 | |
Edwin Kempin | 930187e | 2011-01-27 10:13:42 +0100 | [diff] [blame] | 254 | [[manual_replacement_mapping]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 255 | ==== Manual Replacement Mapping |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 256 | |
David Pursehouse | a3d53c6 | 2014-10-03 12:27:30 +0900 | [diff] [blame] | 257 | .Note |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 258 | **** |
| 259 | The remainder of this section describes a manual method of replacing |
| 260 | changes by matching each commit name to an existing change number. |
| 261 | End-users should instead prefer to use Change-Id lines in their |
| 262 | commit messages, as the process is then fully automated by Gerrit |
| 263 | during normal uploads. |
| 264 | |
| 265 | See above for the preferred technique of replacing changes. |
| 266 | **** |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 267 | |
| 268 | To add an additional patch set to a change, replacing it with an |
| 269 | updated version of the same logical modification, send the new |
| 270 | commit to the change's ref. For example, to add the commit whose |
| 271 | SHA-1 starts with `c0ffee` as a new patch set for change number |
| 272 | `1979`, use the push refspec `c0ffee:refs/changes/1979` as below: |
| 273 | |
| 274 | ==== |
| 275 | git push ssh://sshusername@hostname:29418/projectname c0ffee:refs/changes/1979 |
| 276 | ==== |
| 277 | |
| 278 | This form can be combined together with `refs/for/'branchname'` |
| 279 | (above) to simultaneously create new changes and replace changes |
| 280 | during one network transaction. |
| 281 | |
| 282 | For example, consider the following sequence of events: |
| 283 | |
| 284 | ==== |
| 285 | $ git commit -m A ; # create 3 commits |
| 286 | $ git commit -m B |
| 287 | $ git commit -m C |
| 288 | |
| 289 | $ git push ... HEAD:refs/for/master ; # upload for review |
| 290 | ... A is 1500 ... |
| 291 | ... B is 1501 ... |
| 292 | ... C is 1502 ... |
| 293 | |
| 294 | $ git rebase -i HEAD~3 ; # edit "A", insert D before B |
| 295 | ; # now series is A'-D-B'-C' |
Shawn O. Pearce | d607846 | 2009-11-02 10:37:01 -0800 | [diff] [blame] | 296 | $ git push ... |
| 297 | HEAD:refs/for/master |
| 298 | HEAD~3:refs/changes/1500 |
| 299 | HEAD~1:refs/changes/1501 |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 300 | HEAD~0:refs/changes/1502 ; # upload replacements |
| 301 | ==== |
| 302 | |
| 303 | At the final step during the push Gerrit will attach A' as a new |
| 304 | patch set on change 1500; B' as a new patch set on change 1501; C' |
| 305 | as a new patch set on 1502; and D will be created as a new change. |
| 306 | |
| 307 | Ensuring D is created as a new change requires passing the refspec |
| 308 | `HEAD:refs/for/branchname`, otherwise Gerrit will ignore D and |
| 309 | won't do anything with it. For this reason it is a good idea to |
| 310 | always include the create change refspec when uploading replacements. |
| 311 | |
| 312 | |
Edwin Kempin | 913eab1 | 2011-05-06 08:18:24 +0200 | [diff] [blame] | 313 | [[bypass_review]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 314 | === Bypass Review |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 315 | |
| 316 | Changes (and annotated tags) can be pushed directly into a |
| 317 | repository, bypassing the review process. This is primarily useful |
| 318 | for a project owner to create new branches, create annotated tags |
| 319 | for releases, or to force-update a branch whose history needed to |
| 320 | be rewritten. |
| 321 | |
| 322 | Gerrit restricts direct pushes that bypass review to: |
| 323 | |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 324 | * `+refs/heads/*+`: any branch can be updated, created, deleted, |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 325 | or rewritten by the pusher. |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 326 | * `+refs/tags/*+`: annotated tag objects pointing to any other type |
Nico Sallembien | 950e415 | 2010-03-16 15:45:33 -0700 | [diff] [blame] | 327 | of Git object can be created. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 328 | |
Fredrik Luthander | c10f9e7 | 2012-01-23 17:00:45 +0100 | [diff] [blame] | 329 | To push branches, the proper access rights must be configured first. |
| 330 | 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] | 331 | |
| 332 | * Update: Any existing branch can be fast-forwarded to a new commit. |
| 333 | This is the safest mode as commits cannot be discarded. Creation |
Fredrik Luthander | c10f9e7 | 2012-01-23 17:00:45 +0100 | [diff] [blame] | 334 | of new branches is rejected. Can be configured with |
| 335 | link:access-control.html#category_push_direct['Push'] access. |
| 336 | * Create: Allows creation of a new branch if the name does not |
| 337 | already designate an existing branch name. Needs |
| 338 | link:access-control.html#category_create['Create Reference'] |
| 339 | configured. Please note that once created, this permission doesn't |
| 340 | grant the right to update the branch with further commits (see above |
| 341 | for update details). |
| 342 | * Delete: Implies Update, but also allows an existing |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 343 | branch to be deleted. Since a force push is effectively a delete |
| 344 | followed by a create, but performed atomically on the server and |
| 345 | logged, this also permits forced push updates to branches. |
Fredrik Luthander | c10f9e7 | 2012-01-23 17:00:45 +0100 | [diff] [blame] | 346 | To grant this access, configure |
| 347 | link:access-control.html#category_push_direct['Push'] with the |
| 348 | 'Force' option ticked. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 349 | |
| 350 | To push annotated tags, the `Push Annotated Tag` project right must |
| 351 | be granted to one (or more) of the user's groups. There is only |
| 352 | one level of access in this category. |
| 353 | |
| 354 | Project owners may wish to grant themselves `Push Annotated Tag` |
| 355 | only at times when a new release is being prepared, and otherwise |
| 356 | grant nothing at all. This ensures that accidental pushes don't |
| 357 | make undesired changes to the public repository. |
| 358 | |
| 359 | |
Edwin Kempin | bfa0621 | 2013-04-04 16:06:39 +0200 | [diff] [blame] | 360 | [[auto_merge]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 361 | === Auto-Merge during Push |
Edwin Kempin | bfa0621 | 2013-04-04 16:06:39 +0200 | [diff] [blame] | 362 | |
| 363 | Changes can be directly submitted on push. This is primarily useful |
| 364 | for teams that don't want to do code review but want to use Gerrit's |
| 365 | submit strategies to handle contention on busy branches. Using |
| 366 | `%submit` creates a change and submits it immediately, if the caller |
| 367 | has link:access-control.html#category_submit[Submit] permission on |
| 368 | `refs/for/<ref>` (e.g. on `refs/for/refs/heads/master`). |
| 369 | |
| 370 | ==== |
| 371 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%submit |
| 372 | ==== |
| 373 | |
| 374 | On auto-merge of a change neither labels nor submit rules are checked. |
| 375 | If the merge fails the change stays open, but when pushing a new patch |
| 376 | set the merge can be reattempted by using `%submit` again. |
| 377 | |
| 378 | |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 379 | [[base]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 380 | === Selecting Merge Base |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 381 | |
| 382 | By default new changes are opened only for new unique commits |
| 383 | that have never before been seen by the Gerrit server. Clients |
| 384 | may override that behavior and force new changes to be created |
| 385 | by setting the merge base SHA-1 using the '%base' argument: |
| 386 | |
| 387 | ==== |
| 388 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=$(git rev-parse origin/master) |
| 389 | ==== |
| 390 | |
Sasa Zivkov | bc011a1 | 2013-11-07 16:08:31 +0100 | [diff] [blame] | 391 | It is also possible to specify more than one '%base' argument. |
| 392 | This may be useful when pushing a merge commit. Note that the '%' |
| 393 | character has only to be provided once, for the first '%base' |
| 394 | argument: |
| 395 | |
| 396 | ==== |
| 397 | git push ssh://john.doe@git.example.com:29418/kernel/common HEAD:refs/for/master%base=commit-id1,base=commit-id2 |
| 398 | ==== |
| 399 | |
Shawn Pearce | 5d8a290 | 2013-04-22 11:50:23 -0700 | [diff] [blame] | 400 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 401 | == repo upload |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 402 | |
| 403 | repo is a multiple repository management tool, most commonly |
| 404 | used by the Android Open Source Project. For more details, see |
Orgad Shaneh | c9e11de | 2012-12-24 16:49:09 +0200 | [diff] [blame] | 405 | link:http://source.android.com/source/using-repo.html[using repo]. |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 406 | |
| 407 | [[repo_create]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 408 | === Create Changes |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 409 | |
| 410 | To upload changes to a project using `repo`, ensure the manifest's |
| 411 | review field has been configured to point to the Gerrit server. |
| 412 | Only the hostname or the web address needs to be given in the |
| 413 | manifest file. During upload `repo` will automatically determine the |
| 414 | correct port number by reading `http://'reviewhostname'/ssh_info` |
| 415 | when its invoked. |
| 416 | |
| 417 | Each new commit uploaded by `repo upload` will be converted into |
| 418 | a change record on the server. Other users (e.g. project owners) |
| 419 | who have configured Gerrit to notify them of new changes will be |
| 420 | automatically sent an email message. Additional notifications can |
| 421 | be sent through command line options. |
| 422 | |
| 423 | For more details on using `repo upload`, see `repo help upload`. |
| 424 | |
| 425 | [[repo_replace]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 426 | === Replace Changes |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 427 | |
| 428 | To replace changes, ensure Change-Id lines were created in the |
Cecilia Svensson | cd2491d | 2012-01-20 14:22:30 +0100 | [diff] [blame] | 429 | commit messages, and just use `repo upload`. |
| 430 | Gerrit Code Review will automatically match the commits back to |
| 431 | their original changes by taking advantage of their Change-Id lines. |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 432 | |
| 433 | If Change-Id lines are not present in the commit messages, consider |
| 434 | amending the message and copying the line from the change's page |
| 435 | on the web. |
| 436 | |
| 437 | If Change-Id lines are not available, then the user must use the much |
Cecilia Svensson | cd2491d | 2012-01-20 14:22:30 +0100 | [diff] [blame] | 438 | more <<manual_replacement_mapping,manual mapping technique>> offered |
| 439 | by using `git push` to a specific `refs/changes/change#` reference. |
Shawn O. Pearce | 518fe3f | 2009-08-22 15:40:58 -0700 | [diff] [blame] | 440 | |
| 441 | For more about Change-Ids, see link:user-changeid.html[Change-Id Lines]. |
| 442 | |
| 443 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 444 | == Gritty Details |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 445 | |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 446 | As Gerrit implements the entire SSH and Git server stack within its |
| 447 | own process space, Gerrit maintains complete control over how the |
| 448 | repository is updated, and what responses are sent to the `git push` |
| 449 | client invoked by the end-user, or by `repo upload`. This allows |
Jonathan Nieder | 5758f18 | 2015-03-30 11:28:55 -0700 | [diff] [blame] | 450 | Gerrit to provide magical refs, such as `+refs/for/*+` for new |
| 451 | change submission and `+refs/changes/*+` for change replacement. |
Shawn O. Pearce | e61a3c6 | 2009-01-29 08:42:41 -0800 | [diff] [blame] | 452 | When a push request is received to create a ref in one of these |
| 453 | namespaces Gerrit performs its own logic to update the database, |
| 454 | and then lies to the client about the result of the operation. |
| 455 | A successful result causes the client to believe that Gerrit has |
| 456 | created the ref, but in reality Gerrit hasn't created the ref at all. |
| 457 | |
| 458 | By implementing the entire server stack, Gerrit is also able to |
| 459 | perform project level access control checks (to verify the end-user |
| 460 | is permitted to access a project) prior to advertising the available |
| 461 | refs, and potentially leaking information to a snooping client. |
| 462 | Clients cannot tell the difference between 'project not found' and |
| 463 | 'project exists, but access is denied'. |
| 464 | |
| 465 | Gerrit can also ensure users have completed a valid Contributor |
| 466 | Agreement prior to accepting any transferred objects, and if an |
| 467 | agreement is required, but not completed, it aborts the network |
| 468 | connection before data is sent. This ensures that project owners |
| 469 | can be certain any object available in their repository has been |
| 470 | supplied under at least one valid agreement. |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 471 | |
| 472 | GERRIT |
| 473 | ------ |
| 474 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 475 | |
| 476 | SEARCHBOX |
| 477 | --------- |