Skip to content

Installing Forgejo or migrating from Gitea

Deploy Forgejo on Ubuntu and migrate an existing Gitea instance — binary swap, database compatibility, repository paths, and the federation flags that distinguish the fork.

Forgejo is the community-governed fork of Gitea that emerged in late 2022 when the upstream project announced a commercial entity. For operators the practical difference is small — same Go binary shape, same app.ini, same repo layout — but the governance model, the federation roadmap, and the Codeberg sponsorship matter to teams who want a Git platform that cannot be reshaped by a single vendor. This article covers a fresh install and a clean migration from Gitea.

How to verify

If migrating, snapshot the current Gitea state first. If installing fresh, confirm host shape:

gitea --version 2>/dev/null || echo "no gitea"
systemctl status gitea 2>/dev/null | head -5
psql -U gitea -d gitea -c '\dt' 2>/dev/null | head -10
ls /var/lib/gitea/git/repositories 2>/dev/null | head -5
df -h /var/lib/gitea

Migrations are essentially binary swaps — Forgejo reads Gitea’s app.ini and database verbatim through the 1.x line. The 7.x+ line introduces schema changes that need a one-way migration. Confirm versions before starting.

What’s happening

Forgejo forked from Gitea 1.18 and has tracked feature parity while diverging in two areas: ActivityPub federation (so Forgejo instances can follow each other, eventually) and policy decisions around licensing and packaging. The binary is a drop-in replacement up through the 1.x lineage. From 7.x onward, the file layout, database schema, and app.ini keys diverge enough that you migrate forward but not back without database snapshots.

The migration architecture mistake we see: people stop Gitea, swap the binary, start Forgejo, and skip the database backup. If something goes wrong with a schema upgrade — and across the 1.x → 7.x boundary, something occasionally does — you are stuck without a rollback path. Always snapshot the database first.

The procedure

Fresh install

  1. System packages and user (same as Gitea):

    apt update && apt install -y git postgresql nginx
    adduser --system --shell /bin/bash --group --disabled-password \
      --home /home/git git
  2. Postgres database.

    sudo -u postgres psql <<'SQL'
    CREATE USER forgejo WITH PASSWORD 'replace-me' LOGIN;
    CREATE DATABASE forgejo OWNER forgejo TEMPLATE template0 ENCODING 'UTF8' LC_COLLATE 'C' LC_CTYPE 'C';
    SQL
  3. Fetch the binary.

    FORGEJO_VERSION=7.0.5
    curl -L -o /usr/local/bin/forgejo \
      https://codeberg.org/forgejo/forgejo/releases/download/v${FORGEJO_VERSION}/forgejo-${FORGEJO_VERSION}-linux-amd64
    chmod +x /usr/local/bin/forgejo
  4. Directories, systemd, install — identical to a Gitea install with forgejo in place of gitea in the systemd unit and app.ini path. Use /etc/forgejo/app.ini and /var/lib/forgejo/.

Migration from Gitea

  1. Snapshot the database.

    sudo -u postgres pg_dump -Fc gitea > /var/backups/gitea-pre-forgejo-$(date +%F).dump
  2. Stop Gitea and back up the data directory.

    systemctl stop gitea
    tar czf /var/backups/gitea-data-$(date +%F).tar.gz /var/lib/gitea /etc/gitea
  3. Install the Forgejo binary at the same path. For a 1.x line swap (e.g. Gitea 1.21 → Forgejo 1.21):

    curl -L -o /usr/local/bin/gitea \
      https://codeberg.org/forgejo/forgejo/releases/download/v1.21.11-0/forgejo-1.21.11-0-linux-amd64
    chmod +x /usr/local/bin/gitea
    systemctl start gitea

    Note: we keep the binary at /usr/local/bin/gitea for a 1.x line swap because app.ini and the systemd unit expect that path. Forgejo’s binary will respond to that name without issue.

  4. For the 1.x → 7.x migration, the upstream Forgejo migration guide is the authoritative source. The summary: stop the service, set INSTALL_LOCK=true and RUN_MODE=prod in app.ini, run the binary once with --config /etc/gitea/app.ini doctor convert to upgrade the schema, then start as a service.

  5. Verify after migration.

    sudo -u git /usr/local/bin/gitea --config /etc/gitea/app.ini doctor check
    curl -s https://git.example.com/api/v1/version

    The version endpoint should report a Forgejo string. Issues, PRs, and webhooks should be unchanged.

  6. Rename paths if desired. Many operators keep /var/lib/gitea and /etc/gitea to avoid touching backups, monitoring, and Nginx vhosts. There is no functional reason to rename; do it only when you are also rebuilding monitoring.

Common pitfalls

  • The 1.x → 7.x jump without a database snapshot is the rollback you will not have when something goes wrong; always pg_dump -Fc first.
  • Federation enabled by default in 7.x if you flipped [federation] ENABLED = true exposes activity to the public Fediverse — confirm this is intentional before opening it.
  • The RUN_USER mismatch (Gitea ran as git, you start Forgejo as forgejo) leaves the repository directory owned by the wrong user; either keep git or chown -R the tree.
  • Forgejo Actions runners and Gitea Actions runners are mostly interchangeable but the registration token format changed at some 1.x point; re-register runners after a major upgrade.
  • Keeping the binary path at /usr/local/bin/gitea during a 1.x swap is fine; renaming to forgejo requires updating the systemd unit and any monitoring that greps for gitea in process lists.

Stack Harbor runs Forgejo for clients who want the calm, community-governed Git platform behind their own TLS — Postgres tuned, Actions runners scaled, migrations from Gitea staged with full database snapshots, and the federation flag left intentionally off unless the client has a reason. The procedure above is the migration we run, including the rehearsal we do on a clone of the database before touching production. For clients running this as a managed environment, our managed operations service is the operating model.