I KICKED GITHUB OUT?! Self-Hosting All My Git With Gitea on My Own Server
Every line of code I write lives on my own server now. Not on someone else's platform, not behind someone else's login, not subject to someone else's terms of service changing next quarter. Twelve repositories, every commit, every release, every byte — on a machine I own, in a Docker container I control, at an address I chose: https://git.lightgui.com.
The tool that made it possible is Gitea, a lightweight, self-hosted git forge. This is the full story of how I installed it, configured it, migrated off the big hosted platform, and set up backups — with the exact configuration running live right now, so you can copy it.
Why self-host your git at all?
Git itself is already decentralized — every clone is a full copy of the history. But the forge — the web UI, the issue tracker, the releases, the place your collaborators go — has become centralized in practice. One company holds the forge for most of the world's open-source code, and that has consequences:
- Your code lives on someone else's computer. Your repositories exist at the pleasure of an account, a terms-of-service document, and a billing department. An account suspension, a policy change, or a pricing change can cut you off from your own work.
- Vendor lock-in is real. The longer your issues, releases, wikis, and CI live on one platform, the harder it is to leave. The platform knows it.
- Privacy. Even private repositories on a hosted forge are stored on infrastructure you do not control, mined for telemetry you did not consent to in any meaningful sense, and subject to whatever the operator's current data practices are.
- Cost. Gitea is free and open source. It runs comfortably on the smallest VPS you can rent — a $5-a-month box with 1 GB of RAM is enough for a personal forge. My whole installation, twelve repositories and all, occupies 689 MB on disk.
- No rate limits, no API quotas, no surprises. Push as often as you like. Run as many clones as you like. There is no one throttling you, because there is no one between you and your server.
- Your data is a file on your disk. Repositories are plain git directories. The database is a single SQLite file. The whole thing can be copied, backed up, and restored with ordinary tools. That is the property that matters most — and it is the one no hosted service can offer.
I did not delete anything to make this move. The old hosted repositories still exist, each reduced to a single README that points to the new home. Nothing was lost, nothing was burned. But the canonical home of every project is now mine.
What you need
Almost nothing. A Linux server with Docker and Docker Compose, a domain name (or subdomain) pointing at it, and about ten minutes. My server is a VPS with 30 GB of RAM and a 473 GB disk — wildly more than Gitea needs. Gitea's own footprint is tiny: a single container, a single SQLite database, no separate database server, no Redis, no Elasticsearch. If you can run a web server, you can run Gitea.
The setup below is the exact configuration running live at git.lightgui.com. Swap in your own domain and it is yours.
Installing Gitea with Docker Compose
Gitea ships an official Docker image, and the whole installation is one Compose file. Here is the file live on my server, at /opt/gitea/docker-compose.yml:
# Gitea 28.4.0 — self-hosted git (primary, replaces the hosted forge)
# Data lives in /opt/gitea/data so the backup job can copy it.
# Web: https://git.lightgui.com (reverse proxy -> 172.93.49.176:3000)
# SSH: ssh://git@git.lightgui.com:2222/<owner>/<repo>.git
services:
gitea:
image: gitea/gitea:28.4.0
container_name: gitea
restart: unless-stopped
environment:
- USER_UID=1000
- USER_GID=1000
- RUN_MODE=prod
- APP_NAME=LightGUI Git
- GITEA__database__DB_TYPE=sqlite3
- GITEA__server__DOMAIN=git.lightgui.com
- GITEA__server__ROOT_URL=https://git.lightgui.com/
- GITEA__server__HTTP_PORT=3000
- GITEA__server__SSH_DOMAIN=git.lightgui.com
- GITEA__server__SSH_PORT=2222
- GITEA__server__DISABLE_SSH=false
- GITEA__server__LFS_START_SERVER=true
- GITEA__service__DISABLE_REGISTRATION=true
- GITEA__service__REQUIRE_SIGNIN_VIEW=false
volumes:
- /opt/gitea/data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "2222:22"Then start it:
mkdir -p /opt/gitea/data
cd /opt/gitea
docker compose up -d
docker compose ps
docker exec gitea gitea --versionThat last command should report:
gitea version 28.4.0 built with go1.27.4A few choices in that file deserve explanation, because they are the decisions that make a personal forge work well:
- SQLite, not Postgres or MySQL. For a personal or small-team forge, SQLite is the right database: zero administration, a single file, and Gitea supports it fully. The database lives at
/opt/gitea/data/gitea/db/gitea.dbinside the data volume. No second container to babysit. DISABLE_REGISTRATION=true. Nobody can create an account on your forge unless you create it for them. Your git server is not a public signup form. This is the single most important security setting for a personal instance.REQUIRE_SIGNIN_VIEW=false. Visitors can browse public repositories without logging in. Your code stays readable by the world, while write access stays yours.LFS_START_SERVER=true. Git LFS support. I need it — one of my repositories carries two files of 474 MB and 163 MB that would be absurd as plain git objects. LFS handles them, and Gitea serves them natively.- Port 2222 for SSH. The container's SSH server listens on port 22 internally, mapped to 2222 on the host, because the host's own sshd already owns port 22. Clone URLs therefore look like
ssh://git@git.lightgui.com:2222/thinkmelt/lzply.git. Gitea knows about this throughSSH_DOMAINandSSH_PORT, so the clone URLs it shows in the web UI are correct automatically. /opt/gitea/data:/data. Everything Gitea owns — repositories, the database, avatars, LFS objects — lives in one directory on the host. That is what makes backup trivial, and it is also why the data survives container upgrades untouched.
Running it: first visit and the admin account
Open the web UI. If you are running Gitea on the same machine, that is http://your-server:3000; in my case the public address is https://git.lightgui.com (the reverse proxy, covered next). The first visit shows Gitea's install page.
Because the Compose file already sets the database type, domain, and root URL through environment variables, the install page comes pre-filled. You do not need to touch the database settings at all. The only thing you must do on that page is create the administrator account: a username, an email address, and a password. That account is the keys to the kingdom — pick a strong password and store it in your password manager.
After the install page, Gitea drops you into the dashboard. It is clean, fast, and familiar if you have ever used any git forge: a list of repositories, a "New Repository" button, your profile in the corner. Create your first repository from the UI, or push an existing one from the command line — either way, you are running your own git forge within minutes of starting the container.
Configuring it: HTTPS, SSH, and the settings that matter
HTTPS through a reverse proxy
Gitea itself speaks plain HTTP on port 3000. TLS is the reverse proxy's job. I use Nginx Proxy Manager, with a proxy host pointing at 172.93.49.176:3000 and a Let's Encrypt certificate, so the public address is https://git.lightgui.com. The same job can be done with plain nginx, Caddy, or Traefik — the requirement is just: terminate TLS at the proxy, forward to port 3000, and make sure Gitea's ROOT_URL matches the public https:// address, or the links and clone URLs it generates will be wrong.
One detail worth knowing: when the proxy forwards to Gitea, Gitea needs to trust the X-Forwarded-For and X-Forwarded-Proto headers so it logs real client IPs and generates https:// URLs. The official Docker image and the environment variables above handle the common case; if you use a hand-written nginx config, add the forwarded headers explicitly.
SSH access
Pushing over SSH needs two things: your public key in Gitea, and the right port. Add your key in the web UI under your avatar → Settings → SSH / GPG Keys → Add Key. Paste the contents of your ~/.ssh/id_ed25519.pub (or id_rsa.pub). Then clone with the SSH URL Gitea shows you:
git clone ssh://git@git.lightgui.com:2222/thinkmelt/lzply.gitThe git@ user is the Gitea SSH user — every clone and push goes through it, and Gitea maps the key to your account. The :2222 is the host SSH port from the Compose file. If your host's port 22 is free, you can map 22:22 instead and drop the port from the URL entirely; I keep 2222 because the host sshd already owns 22.
Mail — deliberately off
One setting in my installation is worth a note: mail is disabled. In /opt/gitea/data/gitea/conf/app.ini:
[mailer]
ENABLED = falseThat means Gitea will not send email — no "forgot password" reset links, no notification emails. For a personal forge this is a reasonable trade: it removes an entire moving part (an SMTP server, DNS records, deliverability) and the failure mode is mild, because the admin can reset any password from the admin panel. If you want email, Gitea supports plain SMTP and the settings are a few lines in app.ini — but I would rather have one less service to maintain than a password-reset email I will use twice a year.
Other settings worth knowing
- Registration: off, as above. If you ever want to let a friend in, create their account from the admin panel (Site Administration → User Accounts) instead of opening registration.
- Default branch: Gitea defaults to
main. If your projects usemaster(one of mine does), set the default branch per repository in its settings — Gitea respects it. - LFS: already on in the Compose file. If you push a large file without LFS, Gitea will warn you; the fix is
git lfs trackand a normal push. - Upgrades: change the image tag in the Compose file (
gitea/gitea:28.4.0→ the new version), thendocker compose pull && docker compose up -d. The data volume is untouched, and Gitea runs its own database migrations on startup. Read the release notes first — major versions occasionally need a manual step.
Migrating from the hosted forge
Moving a repository to Gitea is a mirror clone and a mirror push. Nothing is rewritten, no history is lost, tags and branches come across exactly:
# 1. Mirror-clone the repository from its old home
git clone --mirror <old-remote-url> repo.git
cd repo.git
# 2. Create the empty repository in Gitea first (web UI, same name),
# then point the mirror at it and push everything
git remote set-url origin ssh://git@git.lightgui.com:2222/thinkmelt/repo.git
git push --mirror origin
# 3. Verify the two are identical
git ls-remote origin
git ls-remote <old-remote-url>Compare the two ls-remote outputs — every branch and tag hash must match. I verified all twelve repositories this way before touching anything else: lightgui, lightgui_rust, lightgui_python, lzply, lzpaq, sfile, util_box, util_boxgui, rssearch, fftdict-rsi, tkinter_designer, and cwidgets. Twelve out of twelve matched, branch for branch and tag for tag, including the two release tags on lzply and the LFS objects in rssearch.
For repositories you have already cloned locally, re-pointing is one command:
git remote set-url origin ssh://git@git.lightgui.com:2222/thinkmelt/repo.git
git fetch origin
git push origin mainThe redirect: emptying the old repository to a README
I did not delete the old hosted repositories. Deleting is irreversible and it breaks every link anyone ever saved. Instead, each one was emptied down to a single orphan branch containing only a README that points at the new home:
# On a fresh clone of the old repository:
git checkout --orphan redirect
git rm -rf .
cat > README.md <<'EOF'
# repo
The full repository now lives on Gitea:
https://git.lightgui.com/thinkmelt/repo
EOF
git add README.md
git commit -m "Repository moved to Gitea"
git push --force origin redirect
# then delete the old branches and tags, and set `redirect` as the default branchAnyone following an old link lands on a page that tells them exactly where the code went. The old host becomes a signpost, not a graveyard. And if anything ever goes wrong with the self-hosted side, the old repositories are still there as an empty shell you can re-fill — though after the verification step above, you will not need to.
Daily use
Day to day, nothing changes. Clone, commit, push, pull — the same git commands, the same workflow, a different remote. The web UI covers the rest: browsing code, viewing commit history, creating releases, downloading archives, managing issues and pull requests. Releases work exactly as you would expect: create a tag, attach binaries, and Gitea serves them at stable URLs. My lzply releases, five assets each across two versions, moved over with their downloads intact.
One habit worth keeping: after every push, verify it landed. git ls-remote against your Gitea remote takes a second and tells you the truth about what is on the server — which is the whole point of owning the server.
Backups: the part that makes self-hosting safe
The objection everyone raises to self-hosting is the obvious one: what if the server dies? The answer is backups, and Gitea makes them easy — provided you back it up the right way.
The rule is: never rsync a live SQLite database and call it a backup. A SQLite file being written to while you copy it can produce a copy that is corrupt or half a transaction behind, and you will not discover that until the day you need to restore it. The repositories themselves are plain git directories and copy cleanly, but the database needs a consistent snapshot. Gitea ships the tool for exactly that: gitea dump.
docker exec gitea gitea dump \
--skip-repository --skip-log --skip-lfs-data \
--skip-attachment-data --skip-package-data \
--skip-index --skip-custom-dirThat produces a zip containing a consistent copy of the database (plus configuration). The repositories, LFS objects, and attachments are ordinary files, copied separately with rsync. Two layers, each using the right tool for its own kind of data — and the result is a backup you can actually restore from, because the database in it was never mid-write.
My own setup runs that dump every 48 hours as part of the backup sync to a second server, and takes a full cold snapshot — the Gitea data, the database dumps, and the content volumes — once a week to a third machine. The database backup is verified on the receiving end: the zip is opened, the SQLite file is extracted, and PRAGMA integrity_check must return ok, with the repository count matching the live server. A backup that is never verified is a hope, not a backup.
That is the honest trade of self-hosting: you take on the job of backing up. In exchange, the job is small, the tools are standard, and the thing you are protecting is a directory of files you can see — not a row in someone else's database.
Conclusion
Self-hosting git is not a protest and it is not a hobby project. It is the ordinary, practical step of keeping the thing you build with on a machine you control. Gitea makes it cheap: one container, one SQLite file, one Compose file, ten minutes. The migration is a mirror push and a verification command. The backups are a dump and a rsync. And at the end of it, your code lives at an address you own, behind a login you control, on a disk you can touch.
My forge is live at https://git.lightgui.com — twelve repositories, public to read, mine to write. The Gitea project itself is at https://gitea.io. If your code matters to you, give it a home of its own.