gitea

Development moved to Codeberg


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.

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

Commands

web

Starts the server:

admin

Admin operations:

cert

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

dump

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

generate

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

keys

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

...
# 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:

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.

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:

dump-repo

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

restore-repo

Restore-repo restore repository data from disk dir: