Skip to main content

Overview

Gitea provides a comprehensive command-line interface for administrative tasks. All commands are accessed through the gitea binary.

Command Structure

View all available commands:

Admin Commands

The admin command provides administrative operations (see cmd/admin.go:22-89).

User Management

All user management commands are under gitea admin user (see cmd/admin_user.go).

Create User

Create a new user account (see cmd/admin_user_create.go:22-101):
Options:
--username
string
required
Username for the new account
--email
string
required
Email address for the new account
--password
string
Password for the account (required unless using --random-password)
--random-password
boolean
Generate a random password
--random-password-length
number
default:"12"
Length of the generated random password
--admin
boolean
Create user as administrator
--must-change-password
boolean
default:"true"
Require password change on first login (default for all users except the first)
--restricted
boolean
Create as a restricted user account
--user-type
string
default:"individual"
User type: individual or bot
--fullname
string
Full, human-readable name of the user
--access-token
boolean
Generate an access token for the user
--access-token-name
string
default:"gitea-admin"
Name for the generated access token
--access-token-scopes
string
default:"all"
Comma-separated scopes: all, read:user, write:repository, etc.
Examples:

List Users

Displays all registered users.

Change Password

Delete User

Options:
  • --id - Delete by user ID instead of username
  • --purge - Purge user data completely

Generate Access Token

Force Password Change

Authentication Sources

Manage external authentication sources via CLI (see cmd/admin_auth.go).

List Authentication Sources

Outputs a table showing:
  • ID
  • Name
  • Type (LDAP, OAuth2, SMTP, etc.)
  • Enabled status

Add LDAP Authentication

See Authentication Documentation for detailed LDAP configuration.

Add OAuth2 Authentication

Add SMTP Authentication

Update Authentication Source

Delete Authentication Source

Repository Operations

Sync Repository Releases

Synchronize repository releases with Git tags (see cmd/admin.go:98-157):
This command:
  • Scans all repositories
  • Compares tags with releases
  • Creates releases for tags without corresponding releases

Regenerate Data

Regenerate Git hooks and SSH keys (see cmd/admin_regenerate.go).

Regenerate Git Hooks

Regenerates Git hooks for all repositories. Useful after:
  • Gitea upgrades
  • Manual hook modifications
  • Repository corruption

Regenerate SSH Keys

Rebuilds the authorized_keys file from the database.

Send Mail to All Users

Send an administrative message to all users:

Backup and Restore

See Backup and Restore Documentation for complete details.

Create Backup

Restore Repository

Database Operations

Run Migrations

Manually run database migrations.

Migrate Storage

Migrate storage between different backends:
Supported types:
  • lfs - LFS objects
  • avatars - User avatars
  • attachments - Issue/comment attachments
  • packages - Package registry data
  • repo-avatars - Repository avatars

Configuration Management

View Configuration

Displays the effective configuration including:
  • Default values
  • app.ini overrides
  • Environment variable overrides

Logging Management

Doctor Commands

Diagnostic and repair tools:

Available Checks

  • paths - Check path configurations
  • db-version - Verify database version
  • db-consistency - Check database consistency
  • repo-integrity - Verify repository integrity
  • check-hooks - Validate Git hooks
  • check-db-consistency - Advanced database checks
  • authorized-keys - Check SSH authorized_keys file
  • config - Validate configuration

Run Specific Check

Repair Mode

Convert Database Encoding

Certificate Management

Generate Self-Signed Certificate

Outputs:
  • cert.pem - Certificate
  • key.pem - Private key

Web Server

Start Gitea

Options:
  • --port - Override HTTP port
  • --pid - Write PID to file
  • --config - Specify config file location

Generate Commands

Generate Secret Keys

Hook Commands

Internal Git hook commands (used by Git, not for manual execution):

Service Commands

Manager Commands

Environment Variables

Common environment variables for CLI commands:

Best Practices

1

Use Configuration File

Always specify --config or set GITEA_CUSTOM to ensure commands use the correct configuration
2

Run as Correct User

Execute commands as the same user that runs Gitea (typically git)
3

Backup Before Major Operations

Always backup before running regenerate or repair commands
4

Test in Development

Test administrative commands in a development environment first
5

Script Repetitive Tasks

Create scripts for common administrative tasks

Troubleshooting

Command Not Found

Permission Denied

Database Connection Failed