gitea

Development moved to Codeberg

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99
  100. 100
  101. 101
  102. 102
  103. 103
  104. 104
  105. 105
  106. 106
  107. 107
  108. 108
  109. 109
  110. 110
  111. 111
  112. 112
  113. 113
  114. 114
  115. 115
  116. 116
  117. 117
  118. 118
  119. 119
  120. 120
  121. 121
  122. 122
  123. 123
  124. 124
  125. 125
  126. 126
  127. 127
  128. 128
  129. 129
  130. 130
  131. 131
  132. 132
  133. 133
  134. 134
  135. 135
  136. 136
  137. 137
  138. 138
  139. 139
  140. 140
  141. 141
  142. 142
  143. 143
  144. 144
  145. 145
  146. 146
  147. 147
  148. 148
  149. 149
  150. 150
  151. 151
  152. 152
  153. 153
  154. 154
  155. 155
  156. 156
  157. 157
  158. 158
  159. 159
  160. 160
  161. 161
  162. 162
  163. 163
  164. 164
  165. 165
  166. 166
  167. 167
  168. 168
  169. 169
  170. 170
  171. 171
  172. 172
  173. 173
  174. 174
  175. 175
  176. 176
  177. 177
  178. 178
  179. 179
  180. 180
  181. 181
  182. 182
  183. 183
  184. 184
  185. 185
  186. 186
  187. 187
  188. 188
  189. 189
  190. 190
  191. 191
  192. 192
  193. 193
  194. 194
  195. 195
  196. 196
  197. 197
  198. 198
  199. 199
  200. 200
  201. 201
  202. 202
  203. 203
  204. 204
  205. 205
  206. 206
  207. 207
  208. 208
  209. 209
  210. 210
  211. 211
  212. 212
  213. 213
  214. 214
  215. 215
  216. 216
  217. 217
  218. 218
  219. 219
  220. 220
  221. 221
  222. 222
  223. 223
  224. 224
  225. 225
  226. 226
  227. 227
  228. 228
  229. 229
  230. 230
  231. 231
  232. 232
  233. 233
  234. 234
  235. 235
  236. 236
  237. 237
  238. 238
  239. 239
  240. 240
  241. 241
  242. 242
  243. 243
  244. 244
  245. 245
  246. 246
  247. 247
  248. 248
  249. 249
  250. 250
  251. 251
  252. 252
  253. 253
  254. 254
  255. 255
  256. 256
  257. 257
  258. 258
  259. 259
  260. 260
  261. 261
  262. 262
  263. 263
  264. 264
  265. 265
  266. 266
  267. 267
  268. 268
  269. 269
  270. 270
  271. 271
  272. 272
  273. 273
  274. 274
  275. 275
  276. 276
  277. 277
  278. 278
  279. 279
  280. 280
  281. 281
  282. 282
  283. 283
  284. 284
  285. 285
  286. 286
  287. 287
  288. 288
  289. 289
  290. 290
  291. 291
  292. 292
  293. 293
  294. 294
  295. 295
  296. 296
  297. 297
  298. 298
  299. 299
  300. 300
  301. 301
  302. 302
  303. 303
  304. 304
  305. 305
  306. 306
  307. 307
  308. 308
  309. 309
  310. 310
  311. 311
  312. 312
  313. 313
  314. 314
  315. 315
  316. 316
  317. 317
  318. 318
  319. 319
  320. 320
  321. 321
  322. 322
  323. 323
  324. 324
  325. 325
  326. 326
  327. 327
  328. 328
  329. 329
  330. 330
  331. 331
  332. 332
  333. 333
  334. 334
  335. 335
  336. 336
  337. 337
  338. 338
  339. 339
  340. 340
  341. 341
  342. 342
  343. 343
  344. 344
  345. 345
  346. 346
  347. 347
  348. 348
  349. 349
  350. 350
  351. 351
  352. 352
  353. 353
  354. 354
  355. 355
  356. 356
  357. 357
  358. 358
  359. 359
  360. 360
  361. 361
  362. 362
  363. 363
  364. 364
  365. 365
  366. 366
  367. 367
  368. 368
  369. 369
  370. 370
  371. 371
  372. 372
  373. 373
  374. 374
  375. 375
  376. 376
  377. 377
  378. 378
  379. 379
  380. 380
  381. 381
  382. 382
  383. 383
  384. 384
  385. 385
  386. 386
  387. 387
  388. 388
  389. 389
  390. 390
  391. 391
  392. 392
  393. 393
  394. 394
  395. 395
  396. 396
  397. 397
  398. 398
  399. 399
  400. 400
  401. 401
  402. 402
  403. 403
  404. 404
  405. 405
  406. 406
  407. 407
  408. 408
  409. 409
  410. 410
  411. 411
  412. 412
  413. 413
  414. 414
  415. 415
  416. 416
  417. 417
  418. 418
  419. 419
  420. 420
  421. 421
  422. 422
  423. 423
  424. 424
  425. 425
  426. 426
  427. 427
  428. 428
  429. 429
  430. 430
  431. 431
  432. 432
  433. 433
  434. 434
  435. 435
  436. 436
  437. 437
  438. 438
  439. 439
  440. 440
  441. 441
  442. 442
  443. 443
  444. 444
  445. 445
  446. 446
  447. 447
  448. 448
  449. 449
  450. 450
  451. 451
  452. 452
  453. 453
  454. 454
  455. 455
  456. 456
  457. 457
  458. 458
  459. 459
  460. 460
  461. 461
  462. 462
  463. 463
  464. 464
  465. 465
  466. 466
  467. 467
  468. 468
  469. 469
  470. 470
  471. 471
  472. 472
  473. 473
  474. 474
  475. 475
  476. 476
  477. 477
  478. 478
  479. 479
  480. 480
  481. 481
  482. 482
  483. 483
  484. 484
  485. 485
  486. 486
  487. 487
  488. 488
  489. 489
  490. 490
  491. 491
  492. 492
  493. 493
  494. 494
  495. 495
  496. 496
  497. 497
  498. 498
  499. 499
  500. 500
  501. 501
  502. 502
  503. 503
  504. 504
  505. 505
  506. 506
  507. 507
  508. 508
  509. 509
  510. 510
  511. 511
  512. 512
  513. 513
  514. 514
  515. 515
  516. 516
  517. 517
  518. 518
  519. 519
  520. 520
  521. 521
  522. 522
  523. 523
  524. 524
  525. 525
  526. 526
  527. 527
  528. 528
  529. 529
  530. 530
---
date: "2017-01-01T16:00:00+02:00"
title: "Usage: Command Line"
slug: "command-line"
weight: 10
toc: false
draft: false
menu:
  sidebar:
    parent: "usage"
    name: "Command Line"
    weight: 10
    identifier: "command-line"
---

# Command Line

**Table of Contents**

{{< toc >}}

## Usage

`gitea [global options] command [command or global options] [arguments...]`

## Global options

All global options can be placed at the command level.

- `--help`, `-h`: Show help text and exit. Optional.
- `--version`, `-v`: Show version and exit. Optional. (example: `Gitea version 1.1.0+218-g7b907ed built with: bindata, sqlite`).
- `--custom-path path`, `-C path`: Location of the Gitea custom folder. Optional. (default: `AppWorkPath`/custom or `$GITEA_CUSTOM`).
- `--config path`, `-c path`: Gitea configuration file path. Optional. (default: `custom`/conf/app.ini).
- `--work-path path`, `-w path`: Gitea `AppWorkPath`. Optional. (default: LOCATION_OF_GITEA_BINARY or `$GITEA_WORK_DIR`)

NB: The defaults custom-path, config and work-path can also be
changed at build time (if preferred).

## Commands

### web

Starts the server:

- Options:
  - `--port number`, `-p number`: Port number. Optional. (default: 3000). Overrides configuration file.
  - `--install-port number`: Port number to run the install page on. Optional. (default: 3000). Overrides configuration file.
  - `--pid path`, `-P path`: Pidfile path. Optional.
  - `--quiet`, `-q`: Only emit Fatal logs on the console for logs emitted before logging set up.
  - `--verbose`: Emit tracing logs on the console for logs emitted before logging is set-up.
- Examples:
  - `gitea web`
  - `gitea web --port 80`
  - `gitea web --config /etc/gitea.ini --pid /some/custom/gitea.pid`
- Notes:
  - Gitea should not be run as root. To bind to a port below 1024, you can use setcap on
    Linux: `sudo setcap 'cap_net_bind_service=+ep' /path/to/gitea`. This will need to be
    redone every time you update Gitea.

### admin

Admin operations:

- Commands:
  - `user`:
    - `list`:
      - Options:
        - `--admin`: List only admin users. Optional.
      - Description: lists all users that exist
      - Examples:
        - `gitea admin user list`
    - `delete`:
      - Options:
        - `--email`: Email of the user to be deleted.
        - `--username`: Username of user to be deleted.
        - `--id`: ID of user to be deleted.
        - One of `--id`, `--username` or `--email` is required. If more than one is provided then all have to match.
      - Examples:
        - `gitea admin user delete --id 1`
    - `create`:
      - Options:
        - `--name value`: Username. Required. As of Gitea 1.9.0, use the `--username` flag instead.
        - `--username value`: Username. Required. New in Gitea 1.9.0.
        - `--password value`: Password. Required.
        - `--email value`: Email. Required.
        - `--admin`: If provided, this makes the user an admin. Optional.
        - `--access-token`: If provided, an access token will be created for the user. Optional. (default: false).
        - `--must-change-password`: If provided, the created user will be required to choose a newer password after the
          initial login. Optional. (default: true).
        - `--random-password`: If provided, a randomly generated password will be used as the password of the created
          user. The value of `--password` will be discarded. Optional.
        - `--random-password-length`: If provided, it will be used to configure the length of the randomly generated
          password. Optional. (default: 12)
      - Examples:
        - `gitea admin user create --username myname --password asecurepassword --email me@example.com`
    - `change-password`:
      - Options:
        - `--username value`, `-u value`: Username. Required.
        - `--password value`, `-p value`: New password. Required.
      - Examples:
        - `gitea admin user change-password --username myname --password asecurepassword`
  - `regenerate`
    - Options:
      - `hooks`: Regenerate Git Hooks for all repositories
      - `keys`: Regenerate authorized_keys file
    - Examples:
      - `gitea admin regenerate hooks`
      - `gitea admin regenerate keys`
  - `auth`:
    - `list`:
      - Description: lists all external authentication sources that exist
      - Examples:
        - `gitea admin auth list`
    - `delete`:
      - Options:
        - `--id`: ID of source to be deleted. Required.
      - Examples:
        - `gitea admin auth delete --id 1`
    - `add-oauth`:
      - Options:
        - `--name`: Application Name.
        - `--provider`: OAuth2 Provider.
        - `--key`: Client ID (Key).
        - `--secret`: Client Secret.
        - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
        - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
        - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
        - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
        - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
        - `--custom-email-url`: Use a custom Email URL (option for GitHub).
        - `--icon-url`: Custom icon URL for OAuth2 login source.
        - `--skip-local-2fa`: Allow source to override local 2FA. (Optional)
        - `--scopes`: Additional scopes to request for this OAuth2 source. (Optional)
        - `--required-claim-name`: Claim name that has to be set to allow users to login with this source. (Optional)
        - `--required-claim-value`: Claim value that has to be set to allow users to login with this source. (Optional)
        - `--group-claim-name`: Claim name providing group names for this source. (Optional)
        - `--admin-group`: Group Claim value for administrator users. (Optional)
        - `--restricted-group`: Group Claim value for restricted users. (Optional)
      - Examples:
        - `gitea admin auth add-oauth --name external-github --provider github --key OBTAIN_FROM_SOURCE --secret OBTAIN_FROM_SOURCE`
    - `update-oauth`:
      - Options:
        - `--id`: ID of source to be updated. Required.
        - `--name`: Application Name.
        - `--provider`: OAuth2 Provider.
        - `--key`: Client ID (Key).
        - `--secret`: Client Secret.
        - `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
        - `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
        - `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
        - `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
        - `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
        - `--custom-email-url`: Use a custom Email URL (option for GitHub).
        - `--icon-url`: Custom icon URL for OAuth2 login source.
        - `--skip-local-2fa`: Allow source to override local 2FA. (Optional)
        - `--scopes`: Additional scopes to request for this OAuth2 source.
        - `--required-claim-name`: Claim name that has to be set to allow users to login with this source. (Optional)
        - `--required-claim-value`: Claim value that has to be set to allow users to login with this source. (Optional)
        - `--group-claim-name`: Claim name providing group names for this source. (Optional)
        - `--admin-group`: Group Claim value for administrator users. (Optional)
        - `--restricted-group`: Group Claim value for restricted users. (Optional)
      - Examples:
        - `gitea admin auth update-oauth --id 1 --name external-github-updated`
    - `add-smtp`:
      - Options:
        - `--name`: Application Name. Required.
        - `--auth-type`: SMTP Authentication Type (PLAIN/LOGIN/CRAM-MD5). Default to PLAIN.
        - `--host`: SMTP host. Required.
        - `--port`: SMTP port. Required.
        - `--force-smtps`: SMTPS is always used on port 465. Set this to force SMTPS on other ports.
        - `--skip-verify`: Skip TLS verify.
        - `--helo-hostname`: Hostname sent with HELO. Leave blank to send current hostname.
        - `--disable-helo`: Disable SMTP helo.
        - `--allowed-domains`: Leave empty to allow all domains. Separate multiple domains with a comma (',').
        - `--skip-local-2fa`: Skip 2FA to log on.
        - `--active`: This Authentication Source is Activated.
        Remarks:
        `--force-smtps`, `--skip-verify`, `--disable-helo`, `--skip-loca-2fs` and `--active` options can be used in form:
        - `--option`, `--option=true` to enable
        - `--option=false` to disable
        If those options are not specified value would not be changed in `update-smtp` or would use default `false` value in `add-smtp`
      - Examples:
        - `gitea admin auth add-smtp --name ldap --host smtp.mydomain.org --port 587 --skip-verify --active`
    - `update-smtp`:
      - Options:
        - `--id`: ID of source to be updated. Required.
        - other options are shared with `add-smtp`
      - Examples:
        - `gitea admin auth update-smtp --id 1 --host smtp.mydomain.org --port 587 --skip-verify=false`
        - `gitea admin auth update-smtp --id 1 --active=false`
    - `add-ldap`: Add new LDAP (via Bind DN) authentication source
      - Options:
        - `--name value`: Authentication name. Required.
        - `--not-active`: Deactivate the authentication source.
        - `--security-protocol value`: Security protocol name. Required.
        - `--skip-tls-verify`: Disable TLS verification.
        - `--host value`: The address where the LDAP server can be reached. Required.
        - `--port value`: The port to use when connecting to the LDAP server. Required.
        - `--user-search-base value`: The LDAP base at which user accounts will be searched for. Required.
        - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required.
        - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
        - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
        - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
        - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
        - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
        - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
        - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
        - `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
        - `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
        - `--bind-password value`: The password for the Bind DN, if any.
        - `--attributes-in-bind`: Fetch attributes in bind DN context.
        - `--synchronize-users`: Enable user synchronization.
        - `--page-size value`: Search page size.
      - Examples:
        - `gitea admin auth add-ldap --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-search-base "ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(uid=%s))" --email-attribute mail`
    - `update-ldap`: Update existing LDAP (via Bind DN) authentication source
      - Options:
        - `--id value`: ID of authentication source. Required.
        - `--name value`: Authentication name.
        - `--not-active`: Deactivate the authentication source.
        - `--security-protocol value`: Security protocol name.
        - `--skip-tls-verify`: Disable TLS verification.
        - `--host value`: The address where the LDAP server can be reached.
        - `--port value`: The port to use when connecting to the LDAP server.
        - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
        - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate.
        - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
        - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
        - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
        - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
        - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
        - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
        - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
        - `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
        - `--bind-dn value`: The DN to bind to the LDAP server with when searching for the user.
        - `--bind-password value`: The password for the Bind DN, if any.
        - `--attributes-in-bind`: Fetch attributes in bind DN context.
        - `--synchronize-users`: Enable user synchronization.
        - `--page-size value`: Search page size.
      - Examples:
        - `gitea admin auth update-ldap --id 1 --name "my ldap auth source"`
        - `gitea admin auth update-ldap --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`
    - `add-ldap-simple`: Add new LDAP (simple auth) authentication source
      - Options:
        - `--name value`: Authentication name. Required.
        - `--not-active`: Deactivate the authentication source.
        - `--security-protocol value`: Security protocol name. Required.
        - `--skip-tls-verify`: Disable TLS verification.
        - `--host value`: The address where the LDAP server can be reached. Required.
        - `--port value`: The port to use when connecting to the LDAP server. Required.
        - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
        - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate. Required.
        - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
        - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
        - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
        - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
        - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
        - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address. Required.
        - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
        - `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
        - `--user-dn value`: The user’s DN. Required.
      - Examples:
        - `gitea admin auth add-ldap-simple --name ldap --security-protocol unencrypted --host mydomain.org --port 389 --user-dn "cn=%s,ou=Users,dc=mydomain,dc=org" --user-filter "(&(objectClass=posixAccount)(cn=%s))" --email-attribute mail`
    - `update-ldap-simple`: Update existing LDAP (simple auth) authentication source
      - Options:
        - `--id value`: ID of authentication source. Required.
        - `--name value`: Authentication name.
        - `--not-active`: Deactivate the authentication source.
        - `--security-protocol value`: Security protocol name.
        - `--skip-tls-verify`: Disable TLS verification.
        - `--host value`: The address where the LDAP server can be reached.
        - `--port value`: The port to use when connecting to the LDAP server.
        - `--user-search-base value`: The LDAP base at which user accounts will be searched for.
        - `--user-filter value`: An LDAP filter declaring how to find the user record that is attempting to authenticate.
        - `--admin-filter value`: An LDAP filter specifying if a user should be given administrator privileges.
        - `--restricted-filter value`: An LDAP filter specifying if a user should be given restricted status.
        - `--username-attribute value`: The attribute of the user’s LDAP record containing the user name.
        - `--firstname-attribute value`: The attribute of the user’s LDAP record containing the user’s first name.
        - `--surname-attribute value`: The attribute of the user’s LDAP record containing the user’s surname.
        - `--email-attribute value`: The attribute of the user’s LDAP record containing the user’s email address.
        - `--public-ssh-key-attribute value`: The attribute of the user’s LDAP record containing the user’s public ssh key.
        - `--avatar-attribute value`: The attribute of the user’s LDAP record containing the user’s avatar.
        - `--user-dn value`: The user’s DN.
      - Examples:
        - `gitea admin auth update-ldap-simple --id 1 --name "my ldap auth source"`
        - `gitea admin auth update-ldap-simple --id 1 --username-attribute uid --firstname-attribute givenName --surname-attribute sn`

### cert

Generates a self-signed SSL certificate. Outputs to `cert.pem` and `key.pem` in the current
directory and will overwrite any existing files.

- Options:
  - `--host value`: Comma separated hostnames and ips which this certificate is valid for.
    Wildcards are supported. Required.
  - `--ecdsa-curve value`: ECDSA curve to use to generate a key. Optional. Valid options
    are P224, P256, P384, P521.
  - `--rsa-bits value`: Size of RSA key to generate. Optional. Ignored if --ecdsa-curve is
    set. (default: 2048).
  - `--start-date value`: Creation date. Optional. (format: `Jan 1 15:04:05 2011`).
  - `--duration value`: Duration which the certificate is valid for. Optional. (default: 8760h0m0s)
  - `--ca`: If provided, this cert generates it's own certificate authority. Optional.
- Examples:
  - `gitea cert --host git.example.com,example.com,www.example.com --ca`

### dump

Dumps all files and databases into a zip file. Outputs into a file like `gitea-dump-1482906742.zip`
in the current directory.

- Options:
  - `--file name`, `-f name`: Name of the dump file with will be created. Optional. (default: gitea-dump-[timestamp].zip).
  - `--tempdir path`, `-t path`: Path to the temporary directory used. Optional. (default: /tmp).
  - `--skip-repository`, `-R`: Skip the repository dumping. Optional.
  - `--skip-custom-dir`: Skip dumping of the custom dir. Optional.
  - `--database`, `-d`: Specify the database SQL syntax. Optional.
  - `--verbose`, `-V`: If provided, shows additional details. Optional.
- Examples:
  - `gitea dump`
  - `gitea dump --verbose`

### generate

Generates random values and tokens for usage in configuration file. Useful for generating values
for automatic deployments.

- Commands:
  - `secret`:
    - Options:
      - `INTERNAL_TOKEN`: Token used for an internal API call authentication.
      - `JWT_SECRET`: LFS & OAUTH2 JWT authentication secret (LFS_JWT_SECRET is aliased to this option for backwards compatibility).
      - `SECRET_KEY`: Global secret key.
    - Examples:
      - `gitea generate secret INTERNAL_TOKEN`
      - `gitea generate secret JWT_SECRET`
      - `gitea generate secret SECRET_KEY`

### keys

Provides an SSHD AuthorizedKeysCommand. Needs to be configured in the sshd config file:

```ini
...
# The value of -e and the AuthorizedKeysCommandUser should match the
# username running Gitea
AuthorizedKeysCommandUser git
AuthorizedKeysCommand /path/to/gitea keys -e git -u %u -t %t -k %k
```

The command will return the appropriate authorized_keys line for the
provided key. You should also set the value
`SSH_CREATE_AUTHORIZED_KEYS_FILE=false` in the `[server]` section of
`app.ini`.

NB: opensshd requires the Gitea program to be owned by root and not
writable by group or others. The program must be specified by an absolute
path.
NB: Gitea must be running for this command to succeed.

### migrate

Migrates the database. This command can be used to run other commands before starting the server for the first time.  
This command is idempotent.

### convert

Converts an existing MySQL database from utf8 to utf8mb4.

### doctor

Diagnose the problems of current Gitea instance according the given configuration.
Currently there are a check list below:

- Check if OpenSSH authorized_keys file id correct
  When your Gitea instance support OpenSSH, your Gitea instance binary path will be written to `authorized_keys`
  when there is any public key added or changed on your Gitea instance.
  Sometimes if you moved or renamed your Gitea binary when upgrade and you haven't run `Update the '.ssh/authorized_keys' file with Gitea SSH keys. (Not needed for the built-in SSH server.)` on your Admin Panel. Then all pull/push via SSH will not be work.
  This check will help you to check if it works well.

For contributors, if you want to add more checks, you can wrie ad new function like `func(ctx *cli.Context) ([]string, error)` and
append it to `doctor.go`.

```go
var checklist = []check{
	{
		title: "Check if OpenSSH authorized_keys file id correct",
		f:     runDoctorLocationMoved,
    },
    // more checks please append here
}
```

This function will receive a command line context and return a list of details about the problems or error.

#### doctor recreate-table

Sometimes when there are migrations the old columns and default values may be left
unchanged in the database schema. This may lead to warning such as:

```
2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync2() [W] Table user Column keep_activity_private db default is , struct default is 0
```

You can cause Gitea to recreate these tables and copy the old data into the new table
with the defaults set appropriately by using:

```
gitea doctor recreate-table user
```

You can ask Gitea to recreate multiple tables using:

```
gitea doctor recreate-table table1 table2 ...
```

And if you would like Gitea to recreate all tables simply call:

```
gitea doctor recreate-table
```

It is highly recommended to back-up your database before running these commands.

### manager

Manage running server operations:

- Commands:
  - `shutdown`: Gracefully shutdown the running process
  - `restart`: Gracefully restart the running process - (not implemented for windows servers)
  - `flush-queues`: Flush queues in the running process
    - Options:
      - `--timeout value`: Timeout for the flushing process (default: 1m0s)
      - `--non-blocking`: Set to true to not wait for flush to complete before returning
  - `logging`: Adjust logging commands
    - Commands:
      - `pause`: Pause logging
        - Notes:
          - The logging level will be raised to INFO temporarily if it is below this level.
          - Gitea will buffer logs up to a certain point and will drop them after that point.
      - `resume`: Resume logging
      - `release-and-reopen`: Cause Gitea to release and re-open files and connections used for logging (Equivalent to sending SIGUSR1 to Gitea.)
      - `remove name`: Remove the named logger
        - Options:
          - `--group group`, `-g group`: Set the group to remove the sublogger from. (defaults to `default`)
      - `add`: Add a logger
        - Commands:
          - `console`: Add a console logger
            - Options:
              - `--group value`, `-g value`: Group to add logger to - will default to "default"
              - `--name value`, `-n value`: Name of the new logger - will default to mode
              - `--level value`, `-l value`: Logging level for the new logger
              - `--stacktrace-level value`, `-L value`: Stacktrace logging level
              - `--flags value`, `-F value`: Flags for the logger
              - `--expression value`, `-e value`: Matching expression for the logger
              - `--prefix value`, `-p value`: Prefix for the logger
              - `--color`: Use color in the logs
              - `--stderr`: Output console logs to stderr - only relevant for console
          - `file`: Add a file logger
            - Options:
              - `--group value`, `-g value`: Group to add logger to - will default to "default"
              - `--name value`, `-n value`: Name of the new logger - will default to mode
              - `--level value`, `-l value`: Logging level for the new logger
              - `--stacktrace-level value`, `-L value`: Stacktrace logging level
              - `--flags value`, `-F value`: Flags for the logger
              - `--expression value`, `-e value`: Matching expression for the logger
              - `--prefix value`, `-p value`: Prefix for the logger
              - `--color`: Use color in the logs
              - `--filename value`, `-f value`: Filename for the logger -
              - `--rotate`, `-r`: Rotate logs
              - `--max-size value`, `-s value`: Maximum size in bytes before rotation
              - `--daily`, `-d`: Rotate logs daily
              - `--max-days value`, `-D value`: Maximum number of daily logs to keep
              - `--compress`, `-z`: Compress rotated logs
              - `--compression-level value`, `-Z value`: Compression level to use
          - `conn`: Add a network connection logger
            - Options:
              - `--group value`, `-g value`: Group to add logger to - will default to "default"
              - `--name value`, `-n value`: Name of the new logger - will default to mode
              - `--level value`, `-l value`: Logging level for the new logger
              - `--stacktrace-level value`, `-L value`: Stacktrace logging level
              - `--flags value`, `-F value`: Flags for the logger
              - `--expression value`, `-e value`: Matching expression for the logger
              - `--prefix value`, `-p value`: Prefix for the logger
              - `--color`: Use color in the logs
              - `--reconnect-on-message`, `-R`: Reconnect to host for every message
              - `--reconnect`, `-r`: Reconnect to host when connection is dropped
              - `--protocol value`, `-P value`: Set protocol to use: tcp, unix, or udp (defaults to tcp)
              - `--address value`, `-a value`: Host address and port to connect to (defaults to :7020)
          - `smtp`: Add an SMTP logger
            - Options:
              - `--group value`, `-g value`: Group to add logger to - will default to "default"
              - `--name value`, `-n value`: Name of the new logger - will default to mode
              - `--level value`, `-l value`: Logging level for the new logger
              - `--stacktrace-level value`, `-L value`: Stacktrace logging level
              - `--flags value`, `-F value`: Flags for the logger
              - `--expression value`, `-e value`: Matching expression for the logger
              - `--prefix value`, `-p value`: Prefix for the logger
              - `--color`: Use color in the logs
              - `--username value`, `-u value`: Mail server username
              - `--password value`, `-P value`: Mail server password
              - `--host value`, `-H value`: Mail server host (defaults to: 127.0.0.1:25)
              - `--send-to value`, `-s value`: Email address(es) to send to
              - `--subject value`, `-S value`: Subject header of sent emails

### dump-repo

Dump-repo dumps repository data from Git/GitHub/Gitea/GitLab:

- Options:
  - `--git_service service` : Git service, it could be `git`, `github`, `gitea`, `gitlab`, If clone_addr could be recognized, this could be ignored.
  - `--repo_dir dir`, `-r dir`: Repository dir path to store the data 
  - `--clone_addr addr`: The URL will be clone, currently could be a git/github/gitea/gitlab http/https URL. i.e. https://github.com/lunny/tango.git
  - `--auth_username lunny`: The username to visit the clone_addr
  - `--auth_password <password>`: The password to visit the clone_addr
  - `--auth_token <token>`: The personal token to visit the clone_addr
  - `--owner_name lunny`: The data will be stored on a directory with owner name if not empty
  - `--repo_name tango`: The data will be stored on a directory with repository name if not empty
  - `--units <units>`: Which items will be migrated, one or more units should be separated as comma. wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.

### restore-repo

Restore-repo restore repository data from disk dir:

- Options:
  - `--repo_dir dir`, `-r dir`: Repository dir path to restore from
  - `--owner_name lunny`: Restore destination owner name
  - `--repo_name tango`: Restore destination repository name
  - `--units <units>`: Which items will be restored, one or more units should be separated as comma. wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.