Skip to main content
Most people know gogs web for starting the server, but the gogs binary ships with several other commands that help you manage your instance from the command line. Run gogs --help at any time to see the full list of available commands, and gogs <command> --help for details on a specific command.
Every command accepts a --config (-c) flag to specify a custom configuration file path. The default is custom/conf/app.ini.

Starting the server

gogs web
The web command starts the HTTP server that powers the web UI, the REST API, and Git HTTP operations. Use the --port (-p) flag to override the default listening port.

Administration

gogs admin <subcommand>
The admin command lets you perform maintenance tasks without going through the web interface. Available subcommands include:
SubcommandPurpose
create-userCreate a new user account (with optional --admin flag).
delete-inactive-usersRemove user accounts that were never activated.
delete-repository-archivesClean up generated repository archive files.
delete-missing-repositoriesRemove database records for repositories whose Git data is missing on disk.
collect-garbageRun git gc across all repositories.
rewrite-authorized-keysRegenerate the SSH authorized_keys file from the database.
resync-hooksRe-write Git server-side hooks for all repositories.
reinit-missing-repositoriesRe-initialize bare Git repositories that are missing on disk.
rewrite-authorized-keys replaces the entire authorized_keys file. Any non-Gogs keys in that file will be lost.

Importing data

gogs import locale --source <dir> --target <dir>
The import command helps you bring portable data from other Gogs installations into your local instance. Currently the only subcommand is locale, which merges locale files from a source directory into a target directory.

Backup and restore

gogs backup
gogs restore --from <archive>
backup dumps the database, repositories, and related files into a single zip archive. restore imports everything back from an archive, which is useful for migrating Gogs to another server or switching database engines. Both commands support --database-only and --exclude-repos flags to narrow the scope. backup additionally supports --exclude-mirror-repos and --target to control where the archive is saved.

Internal commands

The serv and hook commands are used internally by the SSH and Git subsystems. You generally do not need to invoke them directly, but they are the reason Gogs can handle SSH authentication and server-side Git hooks without any external tooling.