Why Forgejo? A Developer's Guide to Self-Hosted Git Control and Privacy

Pablo at his desk, relieved, viewing Forgejo's interface on his laptop, surrounded by coffee and code.
Pablo finally takes control of his code with Forgejo, no more third-party risks.

Discover why Forgejo is becoming a preferred self-hosted Git alternative, offering control, privacy, and customization for developers seeking to avoid third-party data risks.

Why Forgejo? A Developer’s Quest for Control and Privacy

A few years ago, I found myself in a situation where the very tool I relied on for collaboration and version control became a liability. GitHub, while powerful, came with trade-offs I couldn’t ignore—data privacy concerns, dependency on external infrastructure, and the looming threat of account suspension. That’s when I discovered Forgejo, a self-hosted Git service that offered the same familiar interface but with full control over my code. In this post, I’ll walk you through how I transitioned from GitHub to Forgejo, the challenges I faced, and how it transformed my workflow.

Forgejo isn’t just a GitHub clone; it’s a lightweight, customizable alternative designed for developers who want to run their own private Git server. Whether you’re a solo developer wary of third-party data collection or a team lead seeking to keep sensitive code internal, Forgejo empowers you to reclaim ownership of your repositories. Let’s dive into why this tool has become my go-to solution.

Getting Started with Forgejo: Installation and Configuration

Setting up Forgejo is straightforward, especially if you’re using Docker, which simplifies dependencies and ensures consistency across environments. Here’s how I configured my own instance on a local server:

Step 1: Choose Your Hosting Environment

Forgejo supports multiple deployment methods, including Docker, Kubernetes, and direct installation. For simplicity, I opted for Docker, which allows me to spin up the service with minimal configuration.

Step 2: Run the Docker Command

I used the official Docker image to start the service:

docker run -d --name forgejo \
  -e FORGEJO_POSTGRES_PASSWORD=yourpassword \
  -e FORGEJO_GITLFS_SECRET=yoursecretpassword \
  -p 3000:3000 \
  -v /path/to/data:/data \
  forgejo/forgejo:latest

This command sets up PostgreSQL as the database, configures Git LFS secrets, maps the container’s data directory to a local volume, and exposes the service on port 3000.

Step 3: Access the Web Interface

After a few minutes, Forgejo’s web interface becomes accessible at http://localhost:3000. The initial setup wizard guides you through configuring your instance, including setting up a domain (optional), customizing themes, and enabling features like Git LFS support.

Step 4: Secure Your Instance

For added security, I configured HTTPS using Let’s Encrypt by pointing the domain to my server and enabling the ACME plugin. This ensures all traffic is encrypted and reduces the risk of man-in-the-middle attacks.

By the end of this process, I had a fully functional, private Git server running locally. The flexibility to tweak settings without reliance on external services made it feel like a breath of fresh air compared to GitHub’s rigid ecosystem.

Migrating from GitHub to Forgejo: A Practical Guide

If you’re like me and want to transition your existing GitHub repositories to Forgejo, the process requires a mix of automation and manual oversight. Here’s how I approached it:

1. Clone Repositories Locally

I began by cloning all my GitHub repositories to my local machine using the git clone command. For private repos, I used a personal access token (PAT) to authenticate:

git clone https://<PAT>@github.com/username/repo.git

2. Push to Forgejo

Once cloned, I pushed each repository to Forgejo’s server:

git remote add forgejo git@forgejo-server:username/repo.git  
git push forgejo --force

This step required ensuring that Forgejo’s SSH access was properly configured, which I achieved by setting up SSH keys on my local machine and adding them to Forgejo’s user account.

3. Automate with Scripts

To streamline the process, I wrote a simple Bash script to iterate through all my GitHub repos and automate the cloning and pushing steps. This saved hours of manual work and reduced the chance of errors.

4. Verify and Adjust

After migration, I validated each repository’s integrity by checking commit history and file permissions. Some repos required adjustments to .gitignore files or branch configurations to match Forgejo’s default settings.

Migrating wasn’t without challenges… handling large repositories with Git LFS required additional steps to ensure data integrity.

Why Forgejo Stands Out

Forgejo’s strength lies in its ability to provide full control over your codebase while maintaining a familiar Git workflow. Unlike GitHub’s centralized model, Forgejo’s self-hosted nature allows for:

Conclusion

Migrating from GitHub to Forgejo was a transformative step in my workflow. While the process required time and careful planning, the benefits of control, privacy, and customization far outweighed the initial challenges. For developers seeking to reduce reliance on centralized platforms, Forgejo offers a compelling alternative. If you’re looking to take ownership of your code’s future, it’s worth exploring—and the journey might just be as rewarding as the destination.