blob: c959a07ba0514ad18a1d7b16bef978a876084d57 [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Command Line Tools
Shawn O. Pearce4016a932009-05-28 15:12:40 -07002
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08003== Client
Shawn O. Pearce1f8d0a22009-06-15 18:31:12 -07004
Shawn O. Pearce3e4e8042010-01-29 12:48:21 -08005Client commands and hooks can be downloaded via scp, wget or curl
6from Gerrit's daemon, and then executed on the client system.
Shawn O. Pearceb89e1de2009-08-22 13:31:11 -07007
Shawn O. Pearce3e4e8042010-01-29 12:48:21 -08008To download a client command or hook, use scp or an http client:
Shawn O. Pearceb89e1de2009-08-22 13:31:11 -07009
Michael Ochmannb99feab2016-07-06 14:10:22 +020010----
David Shevitz013d3cb2018-09-21 15:25:45 -070011$ scp -p -P 29418 john.doe@review.example.com:bin/gerrit-cherry-pick ~/bin/
12$ scp -p -P 29418 john.doe@review.example.com:hooks/commit-msg .git/hooks/
Shawn O. Pearceb89e1de2009-08-22 13:31:11 -070013
David Shevitz013d3cb2018-09-21 15:25:45 -070014$ curl -Lo ~/bin/gerrit-cherry-pick http://review.example.com/tools/bin/gerrit-cherry-pick
15$ curl -Lo .git/hooks/commit-msg http://review.example.com/tools/hooks/commit-msg
Michael Ochmannb99feab2016-07-06 14:10:22 +020016----
Shawn O. Pearce3e4e8042010-01-29 12:48:21 -080017
Shawn O. Pearceb89e1de2009-08-22 13:31:11 -070018For more details on how to determine the correct SSH port number,
19see link:user-upload.html#test_ssh[Testing Your SSH Connection].
20
Edwin Kempincf830d52018-08-29 08:36:08 +020021[[client_commands]]
22=== Commands
Shawn O. Pearce1f8d0a22009-06-15 18:31:12 -070023
24link:cmd-cherry-pick.html[gerrit-cherry-pick]::
David Pursehouse4fd86432015-01-09 10:43:58 +090025 Download and cherry-pick one or more changes (commits).
Shawn O. Pearce1f8d0a22009-06-15 18:31:12 -070026
Edwin Kempincf830d52018-08-29 08:36:08 +020027[[client_hooks]]
28=== Hooks
Shawn O. Pearce1f8d0a22009-06-15 18:31:12 -070029
Shawn O. Pearceb89e1de2009-08-22 13:31:11 -070030Client hooks can be installed into a local Git repository, improving
31the developer experience when working with a Gerrit Code Review
32server.
Shawn O. Pearcebb2b5672009-08-21 18:33:10 -070033
34link:cmd-hook-commit-msg.html[commit-msg]::
David Shevitz013d3cb2018-09-21 15:25:45 -070035 Automatically generate `Change-Id:` tags in commit messages.
Shawn O. Pearcebb2b5672009-08-21 18:33:10 -070036
Shawn O. Pearcebb2b5672009-08-21 18:33:10 -070037
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080038== Server
Shawn O. Pearce4016a932009-05-28 15:12:40 -070039
40Aside from the standard Git server side actions, Gerrit supports
41several other commands over its internal SSH daemon. As Gerrit does
42not provide an interactive shell, the commands must be triggered
43from an ssh client, for example:
44
Michael Ochmannb99feab2016-07-06 14:10:22 +020045----
Shawn O. Pearce4016a932009-05-28 15:12:40 -070046 $ ssh -p 29418 review.example.com gerrit ls-projects
Michael Ochmannb99feab2016-07-06 14:10:22 +020047----
Shawn O. Pearce4016a932009-05-28 15:12:40 -070048
49For more details on how to determine the correct SSH port number,
50see link:user-upload.html#test_ssh[Testing Your SSH Connection].
51
Edwin Kempincf830d52018-08-29 08:36:08 +020052[[user_commands]]
53=== User Commands
Shawn O. Pearce4016a932009-05-28 15:12:40 -070054
David Ostrovsky1f04bca2013-10-19 10:38:50 +020055link:cmd-apropos.html[gerrit apropos]::
56 Search Gerrit documentation index.
57
Edwin Kempinf485a0d2012-03-30 08:11:47 +020058link:cmd-ban-commit.html[gerrit ban-commit]::
59 Bans a commit from a project's repository.
60
David Ostrovsky8ece6b02022-06-13 10:29:38 +020061link:cmd-copy-approvals.html[gerrit copy-approvals]::
62 Copy all inferred approvals labels to the latest patch-set.
63
JouYoung Suhf29554a2022-04-07 17:00:29 -040064link:cmd-check-project-access.html[gerrit check-project-access]::
65 Check if user(s) can read non-config refs of a project
66
Hugo Arès169cb232015-01-08 15:40:06 -050067link:cmd-create-branch.html[gerrit create-branch]::
68 Create a new project branch.
69
Edwin Kempincf6c3592011-09-01 15:55:15 +020070link:cmd-ls-groups.html[gerrit ls-groups]::
71 List groups visible to the caller.
72
James Ring8e342722013-05-01 01:40:53 -070073link:cmd-ls-members.html[gerrit ls-members]::
74 List the membership of a group visible to the caller.
75
Shawn O. Pearce47769242011-06-14 16:40:48 -070076link:cmd-ls-projects.html[gerrit ls-projects]::
77 List projects visible to the caller.
78
79link:cmd-query.html[gerrit query]::
Dave Borowitzada289c2018-12-18 13:24:14 -080080 Query the change search index.
Shawn O. Pearce47769242011-06-14 16:40:48 -070081
82'gerrit receive-pack'::
Edwin Kempinf1acbb82011-09-15 12:49:42 +020083 'Deprecated alias for `git receive-pack`.'
Shawn O. Pearce47769242011-06-14 16:40:48 -070084
Hugo Arès169cb232015-01-08 15:40:06 -050085link:cmd-rename-group.html[gerrit rename-group]::
86 Rename an account group.
87
Shawn O. Pearce47769242011-06-14 16:40:48 -070088link:cmd-review.html[gerrit review]::
89 Verify, approve and/or submit a patch set from the command line.
90
Dariusz Luksza55750212015-03-04 16:28:30 +010091link:cmd-set-head.html[gerrit set-head]::
92 Change the HEAD reference of a project.
93
Hugo Arès345b93f2017-04-13 10:08:06 -040094link:cmd-set-project.html[gerrit set-project]::
95 Change a project's settings.
96
Gustaf Lundh7ed07a72018-08-20 15:02:15 +020097link:cmd-set-project-parent.html[gerrit set-project-parent]::
98 Change the project permissions are inherited from.
99
Hugo Arès169cb232015-01-08 15:40:06 -0500100link:cmd-set-reviewers.html[gerrit set-reviewers]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900101 Add or remove reviewers on a change.
Hugo Arès169cb232015-01-08 15:40:06 -0500102
Michael Kellyfc1c3dd2020-03-04 00:40:26 -0800103link:cmd-set-topic.html[gerrit set-topic]::
104 Set the topic for a change.
105
Shawn O. Pearce47769242011-06-14 16:40:48 -0700106link:cmd-stream-events.html[gerrit stream-events]::
Edwin Kempinf1acbb82011-09-15 12:49:42 +0200107 Monitor events occurring in real time.
Shawn O. Pearce47769242011-06-14 16:40:48 -0700108
Magnus Bäckf9b41a42012-09-25 12:20:39 -0400109link:cmd-version.html[gerrit version]::
110 Show the currently executing version of Gerrit.
111
Shawn O. Pearce93599bb2009-06-16 07:27:53 -0700112link:cmd-receive-pack.html[git receive-pack]::
Shawn O. Pearce4016a932009-05-28 15:12:40 -0700113 Standard Git server side command for client side `git push`.
114+
115Also implements the magic associated with uploading commits for
116review. See link:user-upload.html#push_create[Creating Changes].
117
Hugo Arès169cb232015-01-08 15:40:06 -0500118git upload-pack::
David Pursehouse4fd86432015-01-09 10:43:58 +0900119 Standard Git server side command for client side `git fetch`.
Mani Chandel7ec4ac72013-12-10 14:50:33 +0530120
Edwin Kempincf830d52018-08-29 08:36:08 +0200121[[admin_commands]]
122=== Administrator Commands
Shawn O. Pearce4016a932009-05-28 15:12:40 -0700123
Hugo Arès641fc782015-01-08 14:24:07 -0500124link:cmd-close-connection.html[gerrit close-connection]::
125 Close the specified SSH connection.
126
Matthias Sohn0572f5a2021-05-05 09:48:59 +0200127link:cmd-convert-ref-storage.html[gerrit convert-ref-storage]::
128 Convert ref storage to reftable (experimental).
129
Shawn O. Pearceb2ff7c82010-03-20 16:57:36 -0700130link:cmd-create-account.html[gerrit create-account]::
David Pursehousec2683992013-08-24 12:04:52 +0900131 Create a new user account.
Shawn O. Pearceb2ff7c82010-03-20 16:57:36 -0700132
Sasa Zivkov71963a52010-07-30 15:13:58 +0200133link:cmd-create-group.html[gerrit create-group]::
134 Create a new account group.
135
Shawn O. Pearce6e752212009-08-12 12:22:12 -0700136link:cmd-create-project.html[gerrit create-project]::
137 Create a new project and associated Git repository.
138
Shawn O. Pearce4016a932009-05-28 15:12:40 -0700139link:cmd-flush-caches.html[gerrit flush-caches]::
140 Flush some/all server caches from memory.
141
Edwin Kempin619169b2012-02-09 15:47:52 +0100142link:cmd-gc.html[gerrit gc]::
143 Run the Git garbage collection.
144
Khai Do71797a92016-02-25 14:06:21 -0800145link:cmd-index-activate.html[gerrit index activate]::
Hugo Arès47f15be2015-06-30 10:36:08 -0400146 Activate the latest index version available.
147
Hugo Arès3a593352015-06-29 16:04:59 -0400148link:cmd-index-start.html[gerrit index start]::
149 Start the online indexer.
150
David Pursehouse3f99e4e2016-05-20 15:37:18 +0900151link:cmd-index-changes.html[gerrit index changes]::
152 Index one or more changes.
153
Patrick Hiesel20d981e2018-07-04 09:48:21 +0200154link:cmd-index-changes-in-project.html[gerrit index changes-in-project]::
Hector Oswaldo Caballero2b4239a2017-02-13 07:40:33 -0500155 Index all the changes in one or more projects.
156
Simon Leic331a4e2014-08-08 11:12:38 -0400157link:cmd-logging-ls-level.html[gerrit logging ls-level]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900158 List loggers and their logging level.
Simon Leic331a4e2014-08-08 11:12:38 -0400159
160link:cmd-logging-set-level.html[gerrit logging set-level]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900161 Set the logging level of loggers.
Simon Leic331a4e2014-08-08 11:12:38 -0400162
Hugo Arès169cb232015-01-08 15:40:06 -0500163link:cmd-ls-user-refs.html[gerrit ls-user-refs]::
164 Lists refs visible for a specified user.
165
Marcin Czech992867e2021-11-04 16:32:41 +0100166link:cmd-migrate-externalids-to-insensitive.html[gerrit migrate-externalids-to-insensitive]::
167 Migrate external-ids to case insensitive.
168
Edwin Kempinf7295742012-07-16 15:03:46 +0200169link:cmd-plugin-install.html[gerrit plugin add]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900170 Alias for 'gerrit plugin install'.
Edwin Kempinf7295742012-07-16 15:03:46 +0200171
Brad Larsond5e87c32012-07-11 12:18:49 -0500172link:cmd-plugin-enable.html[gerrit plugin enable]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900173 Enable plugins.
Brad Larsond5e87c32012-07-11 12:18:49 -0500174
Edwin Kempinf7295742012-07-16 15:03:46 +0200175link:cmd-plugin-install.html[gerrit plugin install]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900176 Install/Add a plugin.
Edwin Kempinf7295742012-07-16 15:03:46 +0200177
178link:cmd-plugin-ls.html[gerrit plugin ls]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900179 List the installed plugins.
Edwin Kempinf7295742012-07-16 15:03:46 +0200180
181link:cmd-plugin-reload.html[gerrit plugin reload]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900182 Reload/Restart plugins.
Edwin Kempinf7295742012-07-16 15:03:46 +0200183
184link:cmd-plugin-remove.html[gerrit plugin remove]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900185 Disable plugins.
Edwin Kempinf7295742012-07-16 15:03:46 +0200186
187link:cmd-plugin-remove.html[gerrit plugin rm]::
David Pursehouse4fd86432015-01-09 10:43:58 +0900188 Alias for 'gerrit plugin remove'.
Edwin Kempinf7295742012-07-16 15:03:46 +0200189
Gustaf Lundhe0f52ff2018-04-16 10:51:47 +0200190link:cmd-reload-config.html[gerrit reload-config]::
191 Apply an updated gerrit.config.
192
Hugo Arès169cb232015-01-08 15:40:06 -0500193link:cmd-set-account.html[gerrit set-account]::
194 Change an account's settings.
195
David Ostrovsky958c8b72020-07-22 08:36:38 +0200196link:cmd-sequence-set.html[gerrit sequence set]::
197 Set new sequence value.
198
David Ostrovsky4f8df3392019-11-09 14:12:43 -0800199link:cmd-sequence-show.html[gerrit sequence show]::
David Pursehouse8095b862020-03-11 10:16:17 +0900200 Display current sequence value.
David Ostrovsky4f8df3392019-11-09 14:12:43 -0800201
Hugo Arès169cb232015-01-08 15:40:06 -0500202link:cmd-set-members.html[gerrit set-members]::
203 Set group members.
204
Hugo Arès169cb232015-01-08 15:40:06 -0500205link:cmd-show-caches.html[gerrit show-caches]::
206 Display current cache statistics.
207
208link:cmd-show-connections.html[gerrit show-connections]::
209 Display active client SSH connections.
210
211link:cmd-show-queue.html[gerrit show-queue]::
212 Display the background work queues, including replication.
213
Edwin Kempin55210d42013-03-26 10:30:26 +0100214link:cmd-test-submit-rule.html[gerrit test-submit rule]::
Johan Björk20ae0692012-08-02 15:57:13 +0200215 Test prolog submit rules.
216
Edwin Kempin48a9e0d2013-03-26 10:41:46 +0100217link:cmd-test-submit-type.html[gerrit test-submit type]::
218 Test prolog submit type.
219
Shawn O. Pearce3f1a13a2009-11-20 20:15:41 -0800220link:cmd-kill.html[kill]::
221 Kills a scheduled or running task.
222
223link:cmd-show-queue.html[ps]::
224 Alias for 'gerrit show-queue'.
225
Nasser Grainawi21f8fb42010-04-14 16:55:18 -0600226link:cmd-suexec.html[suexec]::
227 Execute a command as any registered user account.
228
Edwin Kempincf830d52018-08-29 08:36:08 +0200229[[trace]]
230=== Trace
Edwin Kempin0ade5aa2018-08-10 08:49:32 +0200231
232For executing SSH commands tracing can be enabled by setting the
Edwin Kempinda823782018-08-29 22:52:54 +0200233`--trace` and `--trace-id <trace-id>` options. It is recommended to use
234the ID of the issue that is being investigated as trace ID.
235
236----
237 $ ssh -p 29418 review.example.com gerrit create-project --trace --trace-id issue/123 foo/bar
238----
239
240It is also possible to omit the trace ID and get a unique trace ID
241generated.
Edwin Kempin0ade5aa2018-08-10 08:49:32 +0200242
243----
244 $ ssh -p 29418 review.example.com gerrit create-project --trace foo/bar
245----
246
247Enabling tracing results in additional logs with debug information that
248are written to the `error_log`. All logs that correspond to the traced
Edwin Kempinda823782018-08-29 22:52:54 +0200249request are associated with the trace ID. The trace ID is printed to
250the stderr command output:
Edwin Kempin0ade5aa2018-08-10 08:49:32 +0200251
252----
253 TRACE_ID: 1534174322774-7edf2a7b
254----
255
256Given the trace ID an administrator can find the corresponding logs and
257investigate issues more easily.
258
Edwin Kempinc67fa222021-08-04 09:30:27 +0200259[[deadline]]
260=== Setting a deadline
261
262When invoking an SSH command it's possible that the client sets a deadline
263after which the request should be aborted. To do this the
264`--deadline <deadline>` option must be set on the request. Values must be
265specified using standard time unit abbreviations ('ms', 'sec', 'min', etc.).
266
267----
268 $ ssh -p 29418 review.example.com gerrit create-project --deadline 5m foo/bar
269----
270
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700271GERRIT
272------
273Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700274
275SEARCHBOX
276---------