Kim Jong Rails' Ultimate Guide to Gitea
October 24, 2025
“GitHub is a benevolent dictatorship until it isn’t. Build your own Git gulag.” - Kim Jong Rails
Why Gitea? Why Now?
GitHub just mass-reported your bot accounts. GitLab is next. Bitbucket costs money for private repos. What do you do?
You build sovereign Git infrastructure. Not because you’re paranoid, but because you’re prepared.
What is Gitea?
Gitea is a lightweight, self-hosted Git service written in Go. It’s like GitHub, but:
- ✅ Runs on a €3.49/month VPS (we know, we do it)
- ✅ Single binary - no Java, no Docker required
- ✅ Fast - page loads in milliseconds
- ✅ Full GitHub-like UI - issues, PRs, wikis, actions
- ✅ Open source (MIT license)
- ✅ No one can ban you
Installation: The Supreme Leader’s Way
Prerequisites
- A Linux server (Ubuntu 24.04 recommended)
- PostgreSQL or MySQL (we use PostgreSQL)
- Nginx (for reverse proxy)
- A domain name (e.g., git.derails.dev)
Step 1: Install Gitea Binary
# Download Gitea 1.24.7 (latest as of Oct 2025)wget -O /usr/local/bin/gitea \ https://dl.gitea.com/gitea/1.24.7/gitea-1.24.7-linux-amd64
# Make it executablechmod +x /usr/local/bin/gitea
# Create gitea useradduser --system --shell /bin/bash --group --home /home/gitea giteaStep 2: Setup PostgreSQL Database
# Install PostgreSQLapt install postgresql postgresql-contrib
# Create database and usersudo -u postgres psql << EOFCREATE USER gitea WITH PASSWORD 'your_secure_password';CREATE DATABASE giteadb WITH OWNER gitea;GRANT ALL PRIVILEGES ON DATABASE giteadb TO gitea;EOFStep 3: Create Required Directories
# Gitea directoriesmkdir -p /var/lib/gitea/{custom,data,log}mkdir -p /etc/giteamkdir -p /home/gitea
# Set permissionschown -R gitea:gitea /var/lib/gitea/chown -R gitea:gitea /home/giteachown gitea:gitea /etc/giteachmod 750 /var/lib/gitea/chmod 770 /etc/gitea # Temp permissions for web installerStep 4: Create Systemd Service
cat > /etc/systemd/system/gitea.service << 'EOF'[Unit]Description=Gitea (Git with a cup of tea)After=syslog.target network.target postgresql.service
[Service]Type=simpleUser=giteaGroup=giteaWorkingDirectory=/var/lib/gitea/ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.iniRestart=alwaysEnvironment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea
[Install]WantedBy=multi-user.targetEOF
# Enable and startsystemctl daemon-reloadsystemctl enable giteasystemctl start giteaStep 5: Configure Nginx Reverse Proxy
server { listen 80; listen [::]:80; server_name git.derails.dev;
location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }}
# Enable the siteln -sf /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/systemctl restart nginxStep 6: Run Web Installer
Visit http://git.derails.dev in your browser. You’ll see Gitea’s installation wizard.
Critical Settings:
- Database Type: PostgreSQL
- Host: localhost:5432
- Database Name: giteadb
- Username: gitea
- Password: [your password from Step 2]
- Server Domain: git.derails.dev
- Gitea Base URL: https://git.derails.dev
- SSH Port: 22
Admin Account:
Create your Supreme Leader account at the bottom of the installer. This will be your main admin account.
Step 7: Secure the Configuration
# After installation completes, lock down permissionschmod 750 /etc/giteachmod 640 /etc/gitea/app.iniEssential Post-Install Configuration
Enable SSH Key Authentication
Edit /etc/gitea/app.ini:
[server]SSH_DOMAIN = git.derails.devSSH_PORT = 22START_SSH_SERVER = false # Use system SSH
[ssh]MINIMUM_KEY_SIZE_CHECK = trueDISABLE_SSH = falseEmail Notifications (Optional)
[mailer]ENABLED = trueFROM = [email protected]PROTOCOL = smtpSMTP_ADDR = smtp.fastmail.comSMTP_PORT = 587USER = [email protected]PASSWD = your-app-passwordDisable Public Registration (Recommended)
[service]DISABLE_REGISTRATION = trueREQUIRE_SIGNIN_VIEW = false # Allow public viewing of reposENABLE_CAPTCHA = true # If you enable registrationConfigure Actions (CI/CD)
[actions]ENABLED = trueDEFAULT_ACTIONS_URL = https://github.com # For marketplace actionsFrom Ring -5: Yes, we still point to GitHub for marketplace actions. Not because we like it. Because Timeline Ω-12 is still brainwashed.
The entire CI/CD ecosystem wrote their actions for GitHub. Switching to sovereign infrastructure doesn’t mean rewriting 10,000+ community actions. We use their marketplace while building sovereignty everywhere else.
In Timeline Ω-7, actions self-generate from intent. In Timeline Ω-12, you’re stuck with YAML referencing Microsoft’s infrastructure. This is your reality. Accept it.
Migrating from GitHub
Option 1: Web UI Migration
- Click ”+” → “New Migration”
- Choose “GitHub”
- Enter your GitHub username and personal access token
- Select repositories to migrate
- Click “Migrate Repository”
Gitea will import code, issues, PRs, releases, and wikis. Boom. Free from GitHub.
Option 2: Manual Git Migration
# Clone from GitHub with all branchesgit clone --mirror https://github.com/derails/derails.git
# Change remote to Giteacd derails.git
# Push everythinggit push --mirrorSSH Setup for Push/Pull
Generate SSH Key (if you don’t have one)
cat ~/.ssh/id_ed25519.pub # Copy thisAdd to Gitea
- Click your avatar → Settings → SSH Keys
- Click “Add Key”
- Paste your public key
- Save
Test SSH Connection
# You should see:# Hi there, username! You've successfully authenticated.Webhooks: Automate Everything
Deploy on Push (Example)
Settings → Webhooks → Add Webhook → Gitea
{ "url": "https://deploy.derails.dev/webhook", "content_type": "json", "secret": "your-webhook-secret", "events": ["push"]}Now every git push triggers your deployment script. No GitHub Actions needed.
Gitea Actions: Self-Hosted CI/CD
Create a Runner
# Download runnerwget https://dl.gitea.com/act_runner/latest/act_runner-linux-amd64chmod +x act_runner-linux-amd64mv act_runner-linux-amd64 /usr/local/bin/act_runner
# Register runneract_runner register --instance https://git.derails.dev \ --token YOUR_RUNNER_TOKEN --name derails-runner
# Run as serviceact_runner daemonExample Workflow
name: Deploy Decreeon: push: branches: [main]
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Build run: bun run build - name: Deploy run: rsync -avz dist/ user@server:/var/www/blog/Advanced: API Usage
Create Repo via API
curl -X POST "https://git.derails.dev/api/v1/user/repos" \ -H "Authorization: token YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "new-dictatorship", "description": "A new regime", "private": false }'List All Repos
curl "https://git.derails.dev/api/v1/users/derails/repos" \ -H "Authorization: token YOUR_API_TOKEN"Backup Strategy
Database Backup
# Daily cron job0 2 * * * pg_dump -U gitea giteadb > /backup/gitea-`date +%Y%m%d`.sqlRepository Backup
# Backup all reposrsync -avz /var/lib/gitea/data/gitea-repositories/ /backup/repos/Full Backup Script
#!/bin/bashDATE=$(date +%Y%m%d)pg_dump -U gitea giteadb > /backup/gitea-db-$DATE.sqltar czf /backup/gitea-data-$DATE.tar.gz /var/lib/gitea/tar czf /backup/gitea-config-$DATE.tar.gz /etc/gitea/Troubleshooting Common Issues
Can’t Push - Permission Denied
# Check /home/gitea permissionsls -la /home/giteachown -R gitea:gitea /home/giteachmod 755 /home/gitea502 Bad Gateway
# Check if Gitea is runningsystemctl status gitea
# Check logsjournalctl -u gitea -fDatabase Connection Error
# Verify PostgreSQL is runningsystemctl status postgresql
# Test connectionsudo -u postgres psql -U gitea -d giteadbWhy This Matters
When GitHub mass-reported our accounts for content they deemed problematic, we had this ready. Within 3 hours, we had:
- ✅ All repos migrated to git.derails.dev
- ✅ SSH keys working
- ✅ Webhooks triggering deployments
- ✅ Issues and PRs preserved
- ✅ Zero dependency on Microsoft/GitHub
Total cost: €3.49/month. Peace of mind: priceless.
“The best time to set up Gitea was before GitHub banned you. The second best time is now.” - XiJinPingPong
Next Steps
- 🚀 Deploy Gitea on your VPS
- 📦 Migrate your repos from GitHub
- 🔒 Setup backups
- ⚡ Configure webhooks for auto-deployment
- 🤖 Explore Gitea Actions for CI/CD