Tech • AI • Robotics • Game

ENFR

You Need to Self-Host GitHub RIGHT NOW!!

5/10
AINetworkChuckNovember 26, 2026 at 10:21 PM25:41
Audio player

⏱ ≈ 4 min read · 26-min video — 22 min saved

TL;DR

Gitea can replace GitHub on a self-managed server with a relatively simple Docker deployment, while preserving core workflows such as repositories, SSH access, pull requests, issue tracking, mirroring and AI-agent automation.

KEY POINTS

Why teams are moving off GitHub

Self-hosting a Git service gives developers control over code availability, access and infrastructure. The main appeal is independence from outages or policy decisions at GitHub, now owned by Microsoft, while keeping repositories reachable on a server the owner controls. The setup is also positioned as a strong fit for AI-assisted coding, especially when teams want code, agents and automation to remain local.

Gitea installed on Ubuntu with Docker

The deployment described uses a fresh Ubuntu virtual machine or VPS and installs Docker plus Docker Compose from Docker’s official repository. A dedicated Gitea directory is created, then configuration is split across a hidden .env file, a standard docker-compose.yaml, and an override file for local settings such as ports, domain and secrets. A randomly generated database password is created with OpenSSL.

Database, domain and TLS setup

The configuration uses PostgreSQL as Gitea’s database backend. Environment variables include a database password, a public domain or local IP, and an ACME email address for certificate management. After docker compose up -d, logs are checked to confirm Let’s Encrypt has issued a TLS certificate, allowing secure access over HTTPS.

First-run configuration and repository creation

On first launch, Gitea presents an initial setup page where most fields are already populated from the compose files. Recommended options include disabling open self-registration and requiring sign-in to view pages, then creating the first administrator account. A first repository is created in the web interface, using a workflow that closely resembles GitHub.

SSH authentication for Git operations

To push code securely, the workflow adds an SSH public key to the Gitea account. New keys can be generated with ed25519, then pasted into the user’s SSH settings in Gitea and verified with a signed token. Once accepted, Git traffic can use the repository’s SSH URL, including a custom SSH port such as 222.

Migrating from GitHub remotes

Existing local repositories can keep GitHub as a secondary remote while making Gitea the new primary target. The origin remote is renamed to GitHub, then a new origin is added for Gitea. A standard git push -u origin main publishes the project, after which files, history and future commits appear in the self-hosted interface.

Bot accounts and AI-agent access

Gitea can create a dedicated bot user for automation. An access token with broad repository permissions is then generated and passed to the official Gitea MCP server, allowing AI tools to query repositories, inspect issues and perform actions. In the example shown, an agent successfully checked the number of open issues and later handled issue-based coding tasks.

Issues, branches and pull requests by AI

The workflow demonstrates an agent reading an issue, creating a branch, committing changes and opening a pull request. A permission problem first blocked the PR because the bot was not yet a collaborator, but the issue was resolved by adding the bot to the repository. After that, the pull request was opened and merged through the web UI in the same style developers expect from hosted Git platforms.

Local AI coding and ownership of the stack

A second issue was assigned to a local model rather than a cloud-hosted one, showing that repository automation can stay under direct operator control. The local model created code changes, opened a PR and produced a dramatic rewrite of a markdown story file. The broader point is that code hosting, Git operations and AI workflows can all run within infrastructure chosen by the developer.

Mirroring back to GitHub

For teams that still want a public presence on GitHub, Gitea supports push mirroring. A GitHub personal access token is created, then added under the repository’s mirror settings in Gitea alongside the destination repository URL. With synchronization enabled, commits pushed to Gitea are automatically replicated to GitHub, giving users private primary hosting and public distribution at the same time.

Basic server hardening

Because the VPS is internet-facing, the setup ends with several security steps. SSH password login is disabled in favor of keys, root login is restricted to key-based authentication, and UFW is configured to rate-limit port 22 and allow only 80, 443 and 222 over TCP. Inside Gitea, two-factor authentication is also enabled for account protection.

CONCLUSION

A self-hosted Gitea deployment can reproduce the core experience of GitHub while giving developers direct control over uptime, access and automation. The main tradeoff is taking responsibility for infrastructure and security, but the result is a private Git platform that can also integrate with both public mirroring and AI-driven workflows.

Ask a question

More from AI