How to Self-Host Gitea as Your Own Git Server

Relying entirely on GitHub or GitLab for every personal project means your code, issues, and history live on someone else’s infrastructure, subject to their pricing changes, outages, or policy shifts. Learning to self-host Gitea as your own Git server gives you a lightweight, full-featured alternative running entirely on your own hardware, with full control over your repositories and data.

What Is Gitea?

Gitea is a free, open-source, lightweight Git server written in Go, offering a GitHub-like experience — repositories, issues, pull requests, wikis, and CI integration — while remaining resource-efficient enough to run comfortably on a Raspberry Pi or a modest homelab VM, unlike heavier alternatives like GitLab.

Why Self-Host Your Git Server

  • Full data ownership – your code and history live entirely on hardware you control
  • No arbitrary limits – no repository count restrictions, storage limits, or feature paywalls tied to a subscription tier
  • Lightweight footprint – Gitea runs comfortably with minimal RAM, unlike GitLab’s considerably heavier resource requirements
  • Private by default – repositories stay entirely internal unless you deliberately expose them, with no risk of accidental public visibility settings

Installing Gitea with Docker

The simplest deployment method uses Docker Compose:

yaml

version: '3'
services:
  gitea:
    image: gitea/gitea:latest
    environment:
      - USER_UID=1000
      - USER_GID=1000
    volumes:
      - ./gitea-data:/data
    ports:
      - '3000:3000'
      - '2222:22'
    restart: unless-stopped
docker compose up -d

Note the second port mapping (2222:22) — this exposes Gitea’s internal SSH service on port 2222 externally, avoiding conflict with your host machine’s own SSH server on port 22.

Completing the Initial Setup

Navigate to http://your-server-ip:3000 and complete the installation wizard, which walks through database configuration (SQLite is fine for most homelab setups, avoiding the need for a separate database server), the site title, and creating your first administrator account.

Creating Your First Repository

  1. Click New Repository from the Gitea dashboard.
  2. Name your repository and choose visibility (private or public).
  3. Clone it using standard Git commands, pointing at your Gitea instance instead of GitHub:
git clone http://your-server-ip:3000/username/repo-name.git

Setting Up SSH Access

For a smoother workflow matching typical GitHub usage, add your SSH public key under Settings → SSH/GPG Keys in Gitea, then clone and push using SSH instead of HTTP:

git clone ssh://git@your-server-ip:2222/username/repo-name.git

Adding CI/CD with Gitea Actions

Modern Gitea versions include built-in Actions support, closely mirroring GitHub Actions syntax, letting you run automated tests or deployment scripts triggered by pushes or pull requests. Enable Actions under your instance’s admin settings, then define workflows in a .gitea/workflows/ directory within any repository using familiar YAML syntax nearly identical to GitHub Actions.

Backing Up Your Gitea Instance

Since Gitea now holds your project history that would otherwise live on GitHub, back it up seriously. The ./gitea-data volume contains everything — repositories, configuration, and the database — so include it in your regular backup routine (covered in earlier Proxmox backup guides if Gitea runs as its own VM).

Migrating Existing Repositories

Gitea includes a built-in migration tool that can import existing repositories directly from GitHub or GitLab, including issues and pull request history where supported, making the transition from a cloud-hosted Git provider considerably less painful than starting from scratch.

Final Thoughts

Choosing to self-host Gitea as your Git server gives you a genuinely capable, GitHub-like experience entirely under your own control, without the resource overhead of heavier alternatives. For homelab users who want full ownership of their code and project history — or simply want one more reason to keep their homelab genuinely useful day to day — Gitea remains one of the easiest self-hosted services to set up and maintain.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *