blob: 108022a977661f06b9430d203f8094db9c8f8d59 [file] [log] [blame]
Marian Harbachebeb1542019-12-13 10:42:46 +01001:linkattrs:
Edwin Kempin1f556222015-04-22 13:24:39 +02002= User Guide
3
4This is a Gerrit guide that is dedicated to Gerrit end-users. It
5explains the standard Gerrit workflows and how a user can adapt Gerrit
6to personal preferences.
7
Marian Harbach34253372019-12-10 18:01:31 +01008It is expected that readers know about link:http://git-scm.com/[Git,role=external,window=_blank]
Edwin Kempin1f556222015-04-22 13:24:39 +02009and that they are familiar with basic git commands and workflows.
10
11[[gerrit]]
12== What is Gerrit?
13
14Gerrit is a Git server that provides link:access-control.html[access
15control] for the hosted Git repositories and a web front-end for doing
16link:#code-review[code review]. Code review is a core functionality of
17Gerrit, but still it is optional and teams can decide to
18link:#no-code-review[work without code review].
19
20[[tools]]
21== Tools
22
Janet Daviesf2c6f622018-03-29 10:40:09 -070023Gerrit uses the git protocol. This means in order to work with Gerrit
Edwin Kempin1f556222015-04-22 13:24:39 +020024you do *not* need to install any Gerrit client, but having a regular
Marian Harbach34253372019-12-10 18:01:31 +010025git client, such as the link:http://git-scm.com/[git command line,role=external,window=_blank] or
26link:http://eclipse.org/egit/[EGit,role=external,window=_blank] in Eclipse, is sufficient.
Edwin Kempin1f556222015-04-22 13:24:39 +020027
28Still there are some client-side tools for Gerrit, which can be used
29optionally:
30
Edwin Kempin4cb451e2015-05-08 09:07:51 +020031* link:https://github.com/uwolfer/gerrit-intellij-plugin[Gerrit
Marian Harbach34253372019-12-10 18:01:31 +010032 IntelliJ Plugin,role=external,window=_blank]: Gerrit integration with the
33 link:http://www.jetbrains.com/idea/[IntelliJ Platform,role=external,window=_blank]
Edwin Kempin37a8ea72024-01-19 08:07:02 +000034* link:https://opendev.org/ttygroup/gertty[gertty]: Console-based interface for Gerrit
Edwin Kempin1f556222015-04-22 13:24:39 +020035
36[[clone]]
37== Clone Gerrit Project
38
39Cloning a Gerrit project is done the same way as cloning any other git
40repository by using the `git clone` command.
41
42.Clone Gerrit Project
43----
44 $ git clone ssh://gerrithost:29418/RecipeBook.git RecipeBook
45 Cloning into RecipeBook...
46----
47
48The URL for cloning the project can be found in the Gerrit web UI
49under `Projects` > `List` > <project-name> > `General`.
50
51For git operations Gerrit supports the link:user-upload.html#ssh[SSH]
52and the link:user-upload.html#http[HTTP/HTTPS] protocols.
53
54[NOTE]
Gert van Dijkdc4f8d12017-08-27 21:14:23 +020055To use SSH you may need to link:user-upload.html#ssh[configure your SSH public
56key in your `Settings`].
Edwin Kempin1f556222015-04-22 13:24:39 +020057
58[[code-review]]
59== Code Review Workflow
60
61With Gerrit _Code Review_ means to link:#review-change[review] every
62commit *before* it is accepted into the code base. The author of a code
63modification link:user-upload.html#push_create[uploads a commit] as a
64change to Gerrit. In Gerrit each change is stored in a
65link:#change-ref[staging area] where it can be checked and reviewed.
66Only when it is approved and submitted it gets applied to the code
67base. If there is feedback on a change, the author can improve the code
68modification by link:#upload-patch-set[amending the commit and
69uploading the new commit as a new patch set]. This way a change is
70improved iteratively and it is applied to the code base only when is
71ready.
72
73[[upload-change]]
74== Upload a Change
75
76Uploading a change to Gerrit is done by pushing a commit to Gerrit. The
77commit must be pushed to a ref in the `refs/for/` namespace which
78defines the target branch: `refs/for/<target-branch>`.
79The magic `refs/for/` prefix allows Gerrit to differentiate commits
80that are pushed for review from commits that are pushed directly into
81the repository, bypassing code review. For the target branch it is
82sufficient to specify the short name, e.g. `master`, but you can also
83specify the fully qualified branch name, e.g. `refs/heads/master`.
84
85.Push for Code Review
86----
87 $ git commit
88 $ git push origin HEAD:refs/for/master
89
90 // this is the same as:
91 $ git commit
92 $ git push origin HEAD:refs/for/refs/heads/master
93----
94
95.Push with bypassing Code Review
96----
97 $ git commit
98 $ git push origin HEAD:master
99
100 // this is the same as:
101 $ git commit
102 $ git push origin HEAD:refs/heads/master
103----
104
105[[push-fails]]
106[NOTE]
107If pushing to Gerrit fails consult the Gerrit documentation that
108explains the link:error-messages.html[error messages].
109
110[[change-ref]]
111When a commit is pushed for review, Gerrit stores it in a staging area
David Pursehousef949a352020-04-19 16:09:44 +0900112which is a branch in the special `refs/changes/` namespace. Understanding
113the format of this ref is not required for working with Gerrit, but it
114is explained below.
115
116A change ref has the format `refs/changes/X/Y/Z` where `X` is the last
117two digits of the change number, `Y` is the entire change number, and `Z`
118is the patch set. For example, if the change number is
David Pursehousebeb74492020-04-29 08:01:37 +0900119link:https://gerrit-review.googlesource.com/c/gerrit/+/263270[263270,role=external,window=_blank],
David Pursehousef949a352020-04-19 16:09:44 +0900120the ref would be `refs/changes/70/263270/2` for the second patch set.
Edwin Kempin1f556222015-04-22 13:24:39 +0200121
122[[fetch-change]]
123Using the change ref git clients can fetch the corresponding commit,
124e.g. for local verification.
125
126.Fetch Change
127----
128 $ git fetch https://gerrithost/myProject refs/changes/74/67374/2 && git checkout FETCH_HEAD
129----
130
131[NOTE]
132The fetch command can be copied from the
133link:user-review-ui.html#download[download commands] in the change
134screen.
135
136The `refs/for/` prefix is used to map the Gerrit concept of
137"Pushing for Review" to the git protocol. For the git client it looks
138like every push goes to the same branch, e.g. `refs/for/master` but in
139fact for each commit that is pushed to this ref Gerrit creates a new
140branch under the `refs/changes/` namespace. In addition Gerrit creates
141an open change.
142
143[[change]]
144A change consists of a link:user-changeid.html[Change-Id], meta data
145(owner, project, target branch etc.), one or more patch sets, comments
146and votes. A patch set is a git commit. Each patch set in a change
147represents a new version of the change and replaces the previous patch
148set. Only the latest patch set is relevant. This means all failed
149iterations of a change will never be applied to the target branch, but
150only the last patch set that is approved is integrated.
151
152[[change-id]]
153The Change-Id is important for Gerrit to know whether a commit that is
154pushed for code review should create a new change or whether it should
155create a new patch set for an existing change.
156
157The Change-Id is a SHA-1 that is prefixed with an uppercase `I`. It is
158specified as footer in the commit message (last paragraph):
159
160----
161 Improve foo widget by attaching a bar.
162
163 We want a bar, because it improves the foo by providing more
164 wizbangery to the dowhatimeanery.
165
166 Bug: #42
167 Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b
168 Signed-off-by: A. U. Thor <author@example.com>
169----
170
171If a commit that has a Change-Id in its commit message is pushed for
172review, Gerrit checks if a change with this Change-Id already exists
173for this project and target branch, and if yes, Gerrit creates a new
174patch set for this change. If not, a new change with the given
175Change-Id is created.
176
177If a commit without Change-Id is pushed for review, Gerrit creates a
178new change and generates a Change-Id for it. Since in this case the
179Change-Id is not included in the commit message, it must be manually
180inserted when a new patch set should be uploaded. Most projects already
181link:project-configuration.html#require-change-id[require a Change-Id]
182when pushing the very first patch set. This reduces the risk of
183accidentally creating a new change instead of uploading a new patch
184set. Any push without Change-Id then fails with
185link:error-missing-changeid.html[missing Change-Id in commit message
Martin Wallgren2db1ecc2018-01-17 08:49:38 +0100186footer].
Edwin Kempin1f556222015-04-22 13:24:39 +0200187
188Amending and rebasing a commit preserves the Change-Id so that the new
189commit automatically becomes a new patch set of the existing change,
190when it is pushed for review.
191
192.Push new Patch Set
193----
194 $ git commit --amend
195 $ git push origin HEAD:refs/for/master
196----
197
198Change-Ids are unique for a branch of a project. E.g. commits that fix
199the same issue in different branches should have the same Change-Id,
200which happens automatically if a commit is cherry-picked to another
201branch. This way you can link:user-search.html[search] by the Change-Id
202in the Gerrit web UI to find a fix in all branches.
203
204Change-Ids can be created automatically by installing the `commit-msg`
205hook as described in the link:user-changeid.html#creation[Change-Id
206documentation].
207
208Instead of manually installing the `commit-msg` hook for each git
209repository, you can copy it into the
210link:http://git-scm.com/docs/git-init#_template_directory[git template
Marian Harbach34253372019-12-10 18:01:31 +0100211directory,role=external,window=_blank]. Then it is automatically copied to every newly cloned
Edwin Kempin1f556222015-04-22 13:24:39 +0200212repository.
213
214[[review-change]]
215== Review Change
216
217After link:#upload-change[uploading a change for review] reviewers can
218inspect it via the Gerrit web UI. Reviewers can see the code delta and
219link:user-review-ui.html#inline-comments[comment directly in the code]
220on code blocks or lines. They can also link:user-review-ui.html#reply[
221post summary comments and vote on review labels]. The
222link:user-review-ui.html[documentation of the review UI] explains the
223screens and controls for doing code reviews.
224
225There are several options to control how patch diffs should be
226rendered. Users can configure their preferences in the
227link:user-review-ui.html#diff-preferences[diff preferences].
228
229[[upload-patch-set]]
230== Upload a new Patch Set
231
232If there is feedback from code review and a change should be improved a
233new patch set with the reworked code should be uploaded.
234
235This is done by amending the commit of the last patch set. If needed
236this commit can be fetched from Gerrit by using the fetch command from
237the link:user-review-ui.html#download[download commands] in the change
238screen.
239
240It is important that the commit message contains the
241link:user-changeid.html[Change-Id] of the change that should be updated
242as a footer (last paragraph). Normally the commit message already
243contains the correct Change-Id and the Change-Id is preserved when the
244commit is amended.
245
246.Push Patch Set
247----
248 // fetch and checkout the change
249 // (checkout command copied from change screen)
250 $ git fetch https://gerrithost/myProject refs/changes/74/67374/2 && git checkout FETCH_HEAD
251
252 // rework the change
253 $ git add <path-of-reworked-file>
254 ...
255
256 // amend commit
257 $ git commit --amend
258
259 // push patch set
260 $ git push origin HEAD:refs/for/master
261----
262
263[NOTE]
264Never amend a commit that is already part of a central branch.
265
266Pushing a new patch set triggers email notification to the reviewers.
267
268[[multiple-features]]
269== Developing multiple Features in parallel
270
271Code review takes time, which can be used by the change author to
272implement other features. Each feature should be implemented in its own
273local feature branch that is based on the current HEAD of the target
274branch. This way there is no dependency to open changes and new
275features can be reviewed and applied independently. If wanted, it is
276also possible to base a new feature on an open change. This will create
277a dependency between the changes in Gerrit and each change can only be
278applied if all its predecessor are applied as well. Dependencies
279between changes can be seen from the
Peter DeLong553bf202023-09-30 11:29:54 -0400280link:user-review-ui.html#related-changes[Related Changes] tab on
Edwin Kempin1f556222015-04-22 13:24:39 +0200281the change screen.
282
283[[watch]]
284== Watching Projects
285
286To get to know about new changes you can link:user-notify.html#user[
287watch the projects] that you are interested in. For watched projects
288Gerrit sends you email notifications when a change is uploaded or
289modified. You can decide on which events you want to be notified and
290you can filter the notifications by using link:user-search.html[change
291search expressions]. For example '+branch:master file:^.*\.txt$+' would
292send you email notifications only for changes in the master branch that
293touch a 'txt' file.
294
295It is common that the members of a project team watch their own
296projects and then pick the changes that are interesting to them for
297review.
298
299Project owners may also configure
300link:intro-project-owner.html#notifications[notifications on
301project-level].
302
303[[adding-reviewers]]
304== Adding Reviewers
305
306In the link:user-review-ui.html#reviewers[change screen] reviewers can
307be added explicitly to a change. The added reviewer will then be
308notified by email about the review request.
309
310Mainly this functionality is used to request the review of specific
311person who is known to be an expert in the modified code or who is a
312stakeholder of the implemented feature. Normally it is not needed to
313explicitly add reviewers on every change, but you rather rely on the
314project team to watch their project and to process the incoming changes
315by importance, interest, time etc.
316
317There are also link:intro-project-owner.html#reviewers[plugins which
318can add reviewers automatically] (e.g. by configuration or based on git
319blame annotations). If this functionality is required it should be
320discussed with the project owners and the Gerrit administrators.
321
322[[dashboards]]
323== Dashboards
324
325Gerrit supports a wide range of link:user-search.html#search-operators[
326query operators] to search for changes by different criteria, e.g. by
327status, change owner, votes etc.
328
329The page that shows the results of a change query has the change query
330contained in its URL. This means you can bookmark this URL in your
331browser to save the change query. This way it can be easily re-executed
332later.
333
334Several change queries can be also combined into a dashboard. A
335dashboard is a screen in Gerrit that presents the results of several
336change queries in different sections, each section having a descriptive
337title.
338
339A default dashboard is available under `My` > `Changes`. It has
340sections to list outgoing reviews, incoming reviews and recently closed
341changes.
342
343Users can also define link:user-dashboards.html#custom-dashboards[
344custom dashboards]. Dashboards can be bookmarked in a browser so that
345they can be re-executed later.
346
347It is also possible to link:#my-menu[customize the My menu] and add
348menu entries for custom queries or dashboards to it.
349
350Dashboards are very useful to define own views on changes, e.g. you can
351have different dashboards for own contributions, for doing reviews or
352for different sets of projects.
353
354[NOTE]
355You can use the link:user-search.html#limit[limit] and
356link:user-search.html#age[age] query operators to limit the result set
357in a dashboard section. Clicking on the section title executes the
358change query without the `limit` and `age` operator so that you can
359inspect the full result set.
360
361Project owners can also define shared
362link:user-dashboards.html#project-dashboards[dashboards on
363project-level]. The project dashboards can be seen in the web UI under
364`Projects` > `List` > <project-name> > `Dashboards`.
365
Frank Bordenbeda5c82022-07-07 13:41:02 +0200366All dashboards and search pages allow an action to be applied to multiple
367changes at once. Select the changes with the checkboxes on the left side and
368choose the action from the action bar at the top of the change section.
369
Edwin Kempin1f556222015-04-22 13:24:39 +0200370[[submit]]
371== Submit a Change
372
373Submitting a change means that the code modifications of the current
374patch set are applied to the target branch. Submit requires the
375link:access-control.html#category_submit[Submit] access right and is
376done on the change screen by clicking on the
377link:user-review-ui.html#submit[Submit] button.
378
379In order to be submittable changes must first be approved by
380link:user-review-ui.html#vote[voting on the review labels]. By default
381a change can only be submitted if it has a vote with the highest value
382on each review label and no vote with the lowest value (veto vote).
383Projects can configure link:intro-project-owner.html#labels[custom
384labels] and link:intro-project-owner.html#submit-rules[custom submit
385rules] to control when a change becomes submittable.
386
387How the code modification is applied to the target branch when a change
388is submitted is controlled by the
Changcheng Xiao21885982019-01-15 18:16:51 +0100389link:config-project-config.html#submit-type[submit type] which can be
Edwin Kempin1f556222015-04-22 13:24:39 +0200390link:intro-project-owner.html#submit-type[configured on project-level].
391
392Submitting a change may fail with conflicts. In this case you need to
393link:#rebase[rebase] the change locally, resolve the conflicts and
394upload the commit with the conflict resolution as new patch set.
395
396If a change cannot be merged due to path conflicts this is highlighted
397on the change screen by a bold red `Cannot Merge` label.
398
399[[rebase]]
400== Rebase a Change
401
402While a change is in review the HEAD of the target branch can evolve.
403In this case the change can be rebased onto the new HEAD of the target
404branch. When there are no conflicts the rebase can be done directly
405from the link:user-review-ui.html#rebase[change screen], otherwise it
406must be done locally.
407
408.Rebase a Change locally
409----
410 // update the remote tracking branches
411 $ git fetch
412
413 // fetch and checkout the change
414 // (checkout command copied from change screen)
415 $ git fetch https://gerrithost/myProject refs/changes/74/67374/2 && git checkout FETCH_HEAD
416
417 // do the rebase
418 $ git rebase origin/master
419
420 // resolve conflicts if needed and stage the conflict resolution
421 ...
422 $ git add <path-of-file-with-conflicts-resolved>
423
424 // continue the rebase
425 $ git rebase --continue
426
427 // push the commit with the conflict resolution as new patch set
428 $ git push origin HEAD:refs/for/master
429----
430
431Doing a manual rebase is only necessary when there are conflicts that
432cannot be resolved by Gerrit. If manual conflict resolution is needed
433also depends on the link:intro-project-owner.html#submit-type[submit
434type] that is configured for the project.
435
436Generally changes shouldn't be rebased without reason as it
437increases the number of patch sets and creates noise with
438notifications. However if a change is in review for a long time it may
439make sense to rebase it from time to time, so that reviewers can see
440the delta against the current HEAD of the target branch. It also shows
441that there is still an interest in this change.
442
443[NOTE]
444Never rebase commits that are already part of a central branch.
445
Kaushik Lingarkareb09fda2020-06-10 17:59:09 -0700446[[move]]
447== Move a Change
448
449Changes can be link:rest-api-changes.html#move-change[moved] to a desired
450destination branch in the same project. This is useful in cases where
451development activity switches from one branch to another and there is a
452need to move open changes on the inactive branch to the new active one.
453Another useful case is to move changes from a newer branch back to an older
454bugfix branch where an issue first appeared.
455
456Users can move a change only if they have link:access-control.html#category_abandon[
457abandon permission] on the change and link:access-control.html#category_push[
458push permission] on the destination branch.
459
460The move operation will not update the change's parent and users will have
Orgad Shanehde3e3122021-08-30 10:35:40 +0300461to link:#rebase[rebase] the change.
Kaushik Lingarkareb09fda2020-06-10 17:59:09 -0700462
Edwin Kempin1f556222015-04-22 13:24:39 +0200463[[abandon]]
464[[restore]]
465== Abandon/Restore a Change
466
467Sometimes during code review a change is found to be bad and it should
468be given up. In this case the change can be
469link:user-review-ui.html#abandon[abandoned] so that it doesn't appear
470in list of open changes anymore.
471
472Abandoned changes can be link:user-review-ui.html#restore[restored] if
473later they are needed again.
474
Kaushik Lingarkar4a711ed2019-11-12 13:53:29 -0800475[[cherrypickof]]
476== Cherry-Pick changes of a Change
477
478When a change is created/updated using the 'cherry-pick' functionalty,
479the original change and patchset details are recorded in the Change's
480cherrypick field. This field cannot be set or updated by the user in
481any way. It is set automatically after the cherry-pick operation completes
482successfully.
483
Edwin Kempin1f556222015-04-22 13:24:39 +0200484[[topics]]
485== Using Topics
486
487Changes can be grouped by topics. This is useful because it allows you
488to easily find related changes by using the
489link:user-search.html#topic[topic search operator]. Also on the change
490screen link:user-review-ui.html#same-topic[changes with the same topic]
491are displayed so that you can easily navigate between them.
492
493Often changes that together implement a feature or a user story are
494group by a topic.
495
496Assigning a topic to a change can be done in the
497link:user-review-ui.html#project-branch-topic[change screen].
498
499It is also possible to link:user-upload.html#topic[set a topic on
Dan Wang17ced402016-08-26 16:42:49 -0700500push], either by appending `%topic=...` to the ref name or through
501the use of the command line flag `--push-option`, aliased to `-o`,
502followed by `topic=...`.
Edwin Kempin1f556222015-04-22 13:24:39 +0200503
Dave Borowitzc0012512018-03-15 10:28:24 -0400504Gerrit may be link:config-gerrit.html#change.submitWholeTopic[configured] to
505submit all changes in a topic together with a single click, even when topics
506span multiple projects.
507
Edwin Kempin1f556222015-04-22 13:24:39 +0200508.Set Topic on Push
509----
510 $ git push origin HEAD:refs/for/master%topic=multi-master
Dan Wang17ced402016-08-26 16:42:49 -0700511
512 // this is the same as:
513 $ git push origin HEAD:refs/heads/master -o topic=multi-master
Edwin Kempin1f556222015-04-22 13:24:39 +0200514----
515
Albert Cuiacef5c92021-02-26 19:42:27 +0000516For more information about using topics, see the user guide:
517link:cross-repository-changes.html[Submitting Changes Across Repositories by using Topics].
518
Dave Borowitz8fbaddf2018-03-15 10:35:46 -0400519[[hashtags]]
520== Using Hashtags
521
522Hashtags are freeform strings associated with a change, like on social media
523platforms. In Gerrit, you explicitly associate hashtags with changes using a
524dedicated area of the UI; they are not parsed from commit messages or comments.
525
526Similar to topics, hashtags can be used to group related changes together, and
527to search using the link:user-search.html#hashtag[`hashtag:`] operator. Unlike
528topics, a change can have multiple hashtags, and they are only used for
529informational grouping; changes with the same hashtags are not necessarily
530submitted together.
531
Dave Borowitz8fbaddf2018-03-15 10:35:46 -0400532.Set Hashtag on Push
533----
534 $ git push origin HEAD:refs/for/master%t=stable-bugfix
535
536 // this is the same as:
537 $ git push origin HEAD:refs/heads/master -o t=stable-bugfix
538----
539
Dave Borowitzd2e41452017-10-26 08:06:23 -0400540[[wip]]
541== Work-in-Progress Changes
542
543Work-in-Progress (WIP) changes are visible to anyone, but do not notify or
544require an action from a reviewer.
545
546Specifically, when you mark a change as Work-in-Progress:
547
548* Reviewers are not notified for most operations, such as adding or removing,
549 posting comments, and so on. See the REST API documentation
550 link:rest-api-changes.html#set-review-notifications[tables] for more
551 information.
552* The change does not show in reviewers' dashboards.
553
554WIP changes are useful when:
555
556* You have implemented only part of a change, but want to push your change
557 to the server to run tests or perform other actions before requesting
558 reviewer feedback.
559* During a review, you realize you need to rework your change, and you
560 want to stop notifying reviewers of the change until you finish your
561 update.
562
563To set the status of a change to Work-in-Progress, you can use either
564the command line or the user interface. To use the command line, append
565`%wip` to your push request.
566
567----
568 $ git push origin HEAD:refs/for/master%wip
569----
David Pursehouse50016d92019-12-05 16:38:48 +0900570Alternatively, click *WIP* from the *More* menu on the Change screen.
571The Change screen updates with a yellow header, indicating that
572the change is in a Work-in-Progress state.
Dave Borowitzd2e41452017-10-26 08:06:23 -0400573
574To mark the change as ready for review, append `%ready` to your push
575request.
576
577----
578 $ git push origin HEAD:refs/for/master%ready
579----
Sven Selberg86093002020-06-04 17:41:23 +0200580There are two options for marking the change ready for review from the Change
581screen:
582
5831. Click *Start Review* (the primary action *Reply* is renamed when in WIP
584state).
585+
586This will open the reply-modal and allow you to add reviewers and/or CC
587before you start review.
588
5892. Click button *Mark As Active*.
590+
591This will only change the state from WIP to ready, without opening the
592reply-modal.
Dave Borowitzd2e41452017-10-26 08:06:23 -0400593
David Ostrovsky6def4002019-02-03 10:43:47 +0100594Change owners, project owners, site administrators and members of a group that
David Ostrovskyc3f6b142020-07-03 11:53:04 +0000595was granted link:access-control.html#category_toggle_work_in_progress_state[
596Toggle Work In Progress state] permission can mark changes as `work-in-progress`
597and `ready`.
David Ostrovsky44242452018-06-09 20:25:13 +0200598
David Pursehouse4f5fa2a2017-04-05 12:08:05 +0900599[[private-changes]]
600== Private Changes
Edwin Kempin98ddc8a2017-02-21 11:56:08 +0100601
Edwin Kempine2fa2d62018-01-15 09:18:59 +0100602Private changes are changes that are only visible to their owners, reviewers
603and users with the link:access-control.html#category_view_private_changes[
604View Private Changes] global capability. Private changes are useful in a number
605of cases:
Edwin Kempin98ddc8a2017-02-21 11:56:08 +0100606
Sven Selberg03847392019-01-16 14:59:24 +0100607* You want a set of collaborators to review the change before formal review
608 starts. By creating a Private change and adding only a selected few as
609 reviewers you can control who can see the change and get a first opinion
610 before opening up for all reviewers.
611
Sven Selbergc956c412017-09-27 08:01:29 +0200612* You want to check what the change looks like before formal review starts.
David Pursehouseb7f9e2a2017-09-27 13:31:30 +0000613 By marking the change private without reviewers, nobody can
Edwin Kempin98ddc8a2017-02-21 11:56:08 +0100614 prematurely comment on your changes.
615
616* You want to use Gerrit to sync data between different devices. By
617 creating a private throwaway change without reviewers, you can push
618 from one device, and fetch to another device.
619
Edwin Kempin8bb24fe2019-09-27 10:51:42 +0200620Do *not* use private changes for making security fixes (see
Edwin Kempin0118c5d2019-09-27 11:01:26 +0200621link:#private-changes-pitfalls[pitfalls] below). How to make security
622fixes is explained link:#security-fixes[below].
Edwin Kempin98ddc8a2017-02-21 11:56:08 +0100623
624To create a private change, you push it with the `private` option.
625
626.Push a private change
627----
628 $ git commit
629 $ git push origin HEAD:refs/for/master%private
630----
631
632The change will remain private on subsequent pushes until you specify
633the `remove-private` option. Alternatively, the web UI provides buttons
634to mark a change private and non-private again.
635
David Pursehouse47f9d042017-04-12 14:28:14 +0900636When pushing a private change with a commit that is authored by another
637user, the other user will not be automatically added as a reviewer and
638must be explicitly added.
639
Edwin Kempin98ddc8a2017-02-21 11:56:08 +0100640For CI systems that must verify private changes, a special permission
641can be granted
642(link:access-control.html#category_view_private_changes[View Private Changes]).
643In that case, care should be taken to prevent the CI system from
644exposing secret details.
645
Edwin Kempin8bb24fe2019-09-27 10:51:42 +0200646[[private-changes-pitfalls]]
David Pursehouse2ba3b5a2020-06-06 15:04:24 +0900647=== Pitfalls
Edwin Kempin8bb24fe2019-09-27 10:51:42 +0200648
649If private changes are used, be aware of the following pitfalls:
650
651* If a private change gets merged the corresponding commit gets visible
652 for all users that can access the target branch and the private flag
653 from the change is automatically removed. This makes private changes
654 a bad choice for security fixes, as the security fix will be
655 accessible as soon as the change was merged, but for security issues
656 you want to keep an embargo until new releases have been made
657 available.
658* If you push a non-private change on top of a private change the
659 commit of the private change gets implicitly visible through the
660 parent relationship of the follow-up change.
661* If you have a series of private changes and share one with reviewers,
662 the reviewers can also see the commits of the predecessor private
663 changes through the commit parent relationship.
Patrick Georgi7632c9a2021-11-17 20:56:09 +0000664* Users who would have permission to access the change except for its
665 private status and knowledge of its commit ID (e.g. through CI logs
666 or build artifacts containing build numbers) can fetch the code
667 using the commit ID.
Edwin Kempin8bb24fe2019-09-27 10:51:42 +0200668
Edwin Kempin1f556222015-04-22 13:24:39 +0200669[[inline-edit]]
670== Inline Edit
671
672It is possible to link:user-inline-edit.html#editing-change[edit
673changes inline] directly in the web UI. This is useful to make small
674corrections immediately and publish them as a new patch set.
675
676It is also possible to link:user-inline-edit.html#create-change[create
677new changes inline].
678
Edwin Kempin5a2a3382021-04-29 10:07:53 +0000679[[roles]]
680== Roles
681
682Making and reviewing changes usually involves multiple users that
683assume different roles:
684
685- Author:
686+
687The person who wrote the code change. Recorded as author in the Git
688commit.
689
690- Committer:
691+
692The person who created the Git commit, e.g. the person that executed
693the `git commit` command. Recorded as committer in the Git commit.
694
695- Uploader:
696+
697The user that uploaded the commit as a patch set to Gerrit, e.g. the
Edwin Kempinafe41c52021-10-15 08:44:23 +0200698user that executed the `git push` command. For commits that are created through
699an action in the web UI the uploader is the user that triggered the action (e.g.
700if a commit is created by clicking on the `REBASE` button, the user clicking on
701the button becomes the uploader of the newly created commit).
Edwin Kempin5a2a3382021-04-29 10:07:53 +0000702+
703The uploader of the first patch set is the change owner.
704+
705The uploader of the latest patch set, the user that uploaded the
Edwin Kempinc909a162021-10-15 08:38:14 +0200706current patch set, is relevant when
707link:config-labels.html#label_ignoreSelfApproval[self approvals on labels are
708ignored], as in this case approvals from the uploader of the latest patch set
709are ignored.
Edwin Kempin5a2a3382021-04-29 10:07:53 +0000710
711- Change Owner:
712+
713The user that created the change, e.g. uploaded the first patch set.
714
715- Reviewer:
716+
717A user that has reviewed the change or has been asked to review the change.
718
Edwin Kempin5a2a3382021-04-29 10:07:53 +0000719Often one user assumes several of these roles, but it's possible that each role
720is assumed by a different user.
721
Edwin Kempin1f556222015-04-22 13:24:39 +0200722[[project-administration]]
723== Project Administration
724
725Every project has a link:intro-project-owner.html#project-owner[project
726owner] that administrates the project. Project administration includes
727the configuration of the project
728link:intro-project-owner.html#access-rights[access rights], but project
729owners have many more possibilities to customize the workflows for a
730project which are described in the link:intro-project-owner.html[
731project owner guide].
732
733[[no-code-review]]
734== Working without Code Review
735
736Doing code reviews with Gerrit is optional and you can use Gerrit
737without code review as a pure Git server.
738
739.Push with bypassing Code Review
740----
741 $ git commit
742 $ git push origin HEAD:master
743
744 // this is the same as:
745 $ git commit
746 $ git push origin HEAD:refs/heads/master
747----
748
749[NOTE]
750Bypassing code review must be enabled in the project access rights. The
751project owner must allow it by assigning the
752link:access-control.html#category_push_direct[Push] access right on the
753target branch (`refs/heads/<branch-name>`).
754
755[NOTE]
756If you bypass code review you always need to merge/rebase manually if
757the tip of the destination branch has moved. Please keep this in mind
758if you choose to not work with code review because you think it's
759easier to avoid the additional complexity of the review workflow; it
760might actually not be easier.
761
762[NOTE]
763The project owner may enable link:user-upload.html#auto_merge[
764auto-merge on push] to benefit from the automatic merge/rebase on
765server side while pushing directly into the repository.
766
Martin Fick21c557b2015-08-31 16:03:24 -0600767[[user-refs]]
768== User Refs
769
770User configuration data such as link:#preferences[preferences] is
771stored in the `All-Users` project under a per-user ref. The user's
772ref is based on the user's account id which is an integer. The user
773refs are sharded by the last two digits (`+nn+`) in the refname,
774leading to refs of the format `+refs/users/nn/accountid+`.
775
Edwin Kempin1f556222015-04-22 13:24:39 +0200776[[preferences]]
777== Preferences
778
779There are several options to control the rendering in the Gerrit web UI.
780Users can configure their preferences under `Settings` > `Preferences`.
Martin Fick21c557b2015-08-31 16:03:24 -0600781The user's preferences are stored in a `git config` style file named
782`preferences.config` under the link:#user-refs[user's ref] in the
783`All-Users` project.
Edwin Kempin1f556222015-04-22 13:24:39 +0200784
785The following preferences can be configured:
786
Edwin Kempin1f556222015-04-22 13:24:39 +0200787- [[page-size]]`Maximum Page Size`:
788+
789The maximum number of entries that are shown on one page, e.g. used
790when paging through changes, projects, branches or groups.
791
792- [[date-time-format]]`Date/Time Format`:
793+
794The format that should be used to render dates and timestamps.
795
Edwin Kempin717aa5d2016-03-16 16:29:43 +0100796- [[email-notifications]]`Email Notifications`:
797+
798This setting controls the email notifications.
799+
Logan Hanksc88e9612017-09-25 10:17:56 -0700800** [[cc-me]]`Every comment`:
Edwin Kempin717aa5d2016-03-16 16:29:43 +0100801+
802Email notifications are enabled and you get notified by email as CC
803on comments that you write yourself.
804+
Youssef Elghareeb9dddbe02022-02-14 12:52:23 +0100805** `Only comments left by others`
806+
807Email notifications are enabled for all activities excluding comments or
808reviews authored by you.
809+
810** `Only when I am in the attention set`
811+
812Email notifications are only sent if the recipient is in the attention set.
813+
814** `None`:
Edwin Kempin717aa5d2016-03-16 16:29:43 +0100815+
816Email notifications are disabled.
817
Patrick Hiesel006578f2017-02-27 16:26:33 +0100818- [[email-format]]`Email Format`:
819+
820This setting controls the email format Gerrit sends. Note that this
821setting has no effect if the administrator has disabled HTML emails
822for the Gerrit instance.
823+
824** `Plaintext Only`:
825+
826Email notifications contain only plaintext content.
827+
828** `HTML and Plaintext`:
829+
830Email notifications contain both HTML and plaintext content.
831
Edwin Kempind540a252016-09-08 13:29:03 +0200832- [[default-base-for-merges]]`Default Base For Merges`:
833+
834This setting controls which base should be pre-selected in the
835`Diff Against` drop-down list when the change screen is opened for a
836merge commit.
837+
838** `Auto Merge`:
839+
840Pre-selects `Auto Merge` in the `Diff Against` drop-down list when the
841change screen is opened for a merge commit.
842+
843** `First Parent`:
844+
845Pre-selects `Parent 1` in the `Diff Against` drop-down list when the
846change screen is opened for a merge commit.
847+
848
Edwin Kempin717aa5d2016-03-16 16:29:43 +0100849- [[diff-view]]`Diff View`:
850+
851Whether the Side-by-Side diff view or the Unified diff view should be
852shown when clicking on a file path in the change screen.
853
Sebastian Schuberth1ab17d82016-07-28 17:21:29 +0200854- [[show-site-header]]`Show Site Header / Footer`:
Edwin Kempin717aa5d2016-03-16 16:29:43 +0100855+
Sebastian Schuberth1ab17d82016-07-28 17:21:29 +0200856Whether the site header and footer should be shown.
Edwin Kempin717aa5d2016-03-16 16:29:43 +0100857
Edwin Kempin1f556222015-04-22 13:24:39 +0200858- [[relative-dates]]`Show Relative Dates In Changes Table`:
859+
860Whether timestamps in change lists and dashboards should be shown as
861relative timestamps, e.g. '12 days ago' instead of absolute timestamps
862such as 'Apr 15'.
863
864- [[change-size-bars]]`Show Change Sizes As Colored Bars`:
865+
866Whether change sizes should be visualized as colored bars. If disabled
867the numbers of added and deleted lines are shown as text, e.g.
868'+297, -63'.
869
870- [[show-change-number]]`Show Change Number In Changes Table`:
871+
Sven Selberg45ca1782023-01-09 08:32:27 +0000872Whether in change lists and dashboards an `ID` column with the change numbers
873should be shown.
Edwin Kempin1f556222015-04-22 13:24:39 +0200874
875- [[mute-common-path-prefixes]]`Mute Common Path Prefixes In File List`:
876+
877Whether common path prefixes in the file list on the change screen
878should be link:user-review-ui.html#repeating-path-segments[grayed out].
879
Edwin Kempin717aa5d2016-03-16 16:29:43 +0100880- [[inline-signed-off]]`Insert Signed-off-by Footer For Inline Edit Changes`:
Edwin Kempin1f556222015-04-22 13:24:39 +0200881+
Edwin Kempin717aa5d2016-03-16 16:29:43 +0100882Whether a `Signed-off-by` footer should be automatically inserted into
883changes that are created from the web UI (e.g. by the `Create Change`
884and `Edit Config` buttons on the project screen, and the `Follow-Up`
885button on the change screen).
Edwin Kempin1f556222015-04-22 13:24:39 +0200886
Maxime Guerreiro596a9132018-04-06 09:04:16 +0000887- [[publish-comments-on-push]]`Publish comments on push`:
Dave Borowitzd6ee48e2017-04-27 10:32:42 -0400888+
889Whether to publish any outstanding draft comments by default when pushing
890updates to open changes. This preference just sets the default; the behavior can
891still be overridden using a link:user-upload.html#publish-comments[push option].
892
Michael Zhou2e9aca12016-03-17 22:45:40 -0400893- [[use-flash]]`Use Flash Clipboard Widget`:
894+
895Whether the Flash clipboard widget should be used. If enabled and the Flash
896plugin is available, Gerrit offers a copy-to-clipboard icon next to IDs and
897commands that need to be copied frequently, such as the Change-Ids, commit IDs
898and download commands. Note that this option is only shown if the Flash plugin
899is available and the JavaScript Clipboard API is unavailable.
900
David Ostrovsky821c5322018-06-10 16:36:42 +0200901- [[work-in-progress-by-default]]`Set new changes work-in-progress`:
902+
903Whether new changes are uploaded as work-in-progress per default. This
904preference just sets the default; the behavior can still be overridden using a
905link:user-upload.html#wip[push option].
906
Edwin Kempin1f556222015-04-22 13:24:39 +0200907[[my-menu]]
908In addition it is possible to customize the menu entries of the `My`
909menu. This can be used to make the navigation to frequently used
910screens, e.g. configured link:#dashboards[dashboards], quick.
911
Patrick Hiesel4362c4f2017-02-14 11:52:09 +0100912[[reply-by-email]]
913== Reply by Email
914
915Gerrit sends out email notifications to users and supports parsing back replies
David Pursehouseaae0c692017-04-04 15:10:06 +0900916on some of them (when link:config-gerrit.html#receiveemail[configured]).
Patrick Hiesel4362c4f2017-02-14 11:52:09 +0100917
918Gerrit supports replies on these notification emails:
919
920* Notifications about new comments
921* Notifications about new labels that were applied or removed
922
923While Gerrit supports a wide range of email clients, the following ones have
924been tested and are known to work:
925
926* Gmail
927* Gmail Mobile
928
929Gerrit supports parsing back all comment types that can be applied to a change
930via the WebUI:
931
932* Change messages
933* Inline comments
934* File comments
935
936Please note that comments can only be sent in reply to a comment in the original
937notification email, while the change message is independent of those.
938
939Gerrit supports parsing a user's reply from both HTML and plaintext. Please note
940that some email clients extract the text from the HTML email they have received
941and send this back as a quoted reply if you have set the client to plaintext
942mode. In this case, Gerrit only supports parsing a change message. To work
943around this issue, consider setting a <<email-format,User Preference>> to
944receive only plaintext emails.
945
946Example notification:
947----
948Some User has posted comments on this change.
949(https://gerrit-review.googlesource.com/123123 )
950
951Change subject: My new change
952......................................................................
953
954
955Patch Set 3:
956
957Just a couple of smaller things I found.
958
959https://gerrit-review.googlesource.com/#/c/123123/3/MyFile.java
960File
961MyFile.java:
962
963https://gerrit-review.googlesource.com/#/c/123123/3/MyFile@420
964PS3, Line 420: someMethodCall(param);
965Seems to be failing the tests.
966
967
968--
969To view, visit https://gerrit-review.googlesource.com/123123
970To unsubscribe, visit https://gerrit-review.googlesource.com/settings
971
972(Footers omitted for brevity, must be included in all emails)
973----
974
975Example response from the user:
976----
977Thanks, I'll fix it.
978> Some User has posted comments on this change.
979> (https://gerrit-review.googlesource.com/123123 )
980>
981> Change subject: My new change
982> ......................................................................
983>
984>
985> Patch Set 3:
986>
987> Just a couple of smaller things I found.
988>
989> https://gerrit-review.googlesource.com/#/c/123123/3/MyFile.java
990> File
991> MyFile.java:
992Rename this file to File.java
993>
994> https://gerrit-review.googlesource.com/#/c/123123/3/MyFile@420
995> PS3, Line 420: someMethodCall(param);
996> Seems to be failing the tests.
997>
998Yeah, I see why, let me try again.
999>
1000> --
1001> To view, visit https://gerrit-review.googlesource.com/123123
1002> To unsubscribe, visit https://gerrit-review.googlesource.com/settings
1003>
1004> (Footers omitted for brevity, must be included in all emails)
1005----
1006
1007In this case, Gerrit will persist a change message ("Thanks, I'll fix it."),
1008a file comment ("Rename this file to File.java") as well as a reply to an
1009inline comment ("Yeah, I see why, let me try again.").
1010
Edwin Kempin0118c5d2019-09-27 11:01:26 +02001011[[security-fixes]]
Matthias Sohn4819d1e2023-01-09 11:54:56 +01001012== Security Fixes
Edwin Kempin0118c5d2019-09-27 11:01:26 +02001013
1014If a security vulnerability is discovered you normally want to have an
1015embargo about it until fixed releases have been made available. This
1016means you want to develop and review security fixes in private.
1017
1018If your repository is public or grants broad read access it is
1019recommended to fix security issues in a copy of your repository which
1020has very restricted read permissions (e.g. `myproject-security-fixes`).
1021You can then implement, review and submit the security fix in this
1022repository, make and publish a new release and only then integrate the
1023security fix back into the normal (public) repository.
1024
1025Alternatively you can do the security fix in your normal repository in
1026a branch with restricted read permissions. We don't recommend this
1027because there is a risk of configuring the access rights wrongly and
1028unintentionally granting read access to the wrong people.
1029
1030Using private changes for security fixes is *not* recommended due to
1031the link:#private-changes-pitfalls[pitfalls] discussed above.
1032Especially you don't want the fix to become visible after submit and
1033before you had a chance to make and publish a new release.
Edwin Kempin1f556222015-04-22 13:24:39 +02001034
1035GERRIT
1036------
1037Part of link:index.html[Gerrit Code Review]
1038
1039SEARCHBOX
1040---------