Create Your Own Git Server with Gitea

Summary: Host a private Git server using Gitea or Gitolite.


Managing your own Git server can be an empowering step for developers, teams, or organizations that care about privacy, control, or custom workflows. While popular platforms like GitHub and GitLab offer many features, hosting your own service ensures your code and data remain completely under your control.

In this article, we'll explore how to create your personal Git server using Gitea, a lightweight and user-friendly alternative to other Git hosting solutions (we’ll also briefly mention Gitolite for power-user scenarios). Let’s dive into Gitea’s setup, management, and key features to get your own Git hosting up and running.


Why Host Your Own Git Server?

While public Git platforms are excellent for open-source projects and collaboration, there are compelling reasons to run your own:

  • Data Privacy: Your code and metadata stay on infrastructure you control.
  • Customization: Adapt the server to fit unique workflows or integrate with on-premises tools.
  • Cost Savings: For small teams, self-hosting can be cheaper than premium SaaS plans.
  • Learning Experience: Gain firsthand experience in devops, networking, and server management.

What Is Gitea?

Gitea is a painless, self-hosted Git service modeled after GitHub. It’s fast, lightweight, and easy to install, supporting features like web editing, pull requests, issue tracking, and more. Gitea is written in Go, which means it has minimal dependencies and runs on almost any platform.

Key features include:

  • Intuitive web interface
  • Repository and user management
  • Issue tracking and code reviews
  • Wikis and project boards
  • LDAP and OAuth2 authentication options
  • Webhooks and API access

Prerequisites

You'll need:

  • A Linux/Unix server (can also use Windows or macOS)
  • SSH root or sudo access
  • Domain name pointing to your server (optional but recommended)
  • Docker (optional, but makes installation easy)

Step-by-Step: Install Gitea Using Docker

Using Docker is the fastest way to get started.

1. Prepare Your Server

Update your system and install Docker if you haven’t already:

sudo apt update && sudo apt upgrade
sudo apt install docker.io docker-compose

2. Set Up Directories

Create folders for storing Gitea’s data persistently:

mkdir -p ~/gitea/{data,config}

3. Define Docker Compose File

Create a docker-compose.yml file:

version: '3'

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    ports:
      - "3000:3000"    # Web UI
      - "222:22"       # SSH
    volumes:
      - ./gitea/data:/data
      - ./gitea/config:/etc/gitea

Tip: Adjust UID/GID for your user if necessary.

4. Launch Gitea

Run the following command where your docker-compose.yml is located:

docker-compose up -d

Now, navigate to http://<your-server-ip>:3000 to access the web setup interface.

5. Configure Gitea

The initial setup wizard appears in your browser:

  • Database: SQLite is easiest for starters (no external server needed).
  • Repository Root Path: Keep default /data/gitea-repositories.
  • Admin Account: Create your admin user credentials.

Finalize and log in!


Using Gitea

Creating a New Repository

  1. Click the “+” menu > New Repository.
  2. Fill in repository name, description, visibility.
  3. Click Create Repository.

Pushing Code

Clone your repo URL and push as with any Git remote:

git clone git@<your-server-ip>:<user>/<repo>.git

Or over HTTPS:

git clone http://<your-server-ip>:3000/<user>/<repo>.git

Securing and Managing Your Gitea Server

  • Enable HTTPS: Use a reverse proxy like NGINX or Caddy with an SSL certificate (Let’s Encrypt).

  • Backups: Regularly backup the data directory.

  • Updates: Always keep your Gitea image up-to-date:

    docker-compose down
    docker pull gitea/gitea:latest
    docker-compose up -d
    
  • User Management: Invite your team, create organizations, manage permissions through the Gitea web UI.


An Alternative: Gitolite

Gitolite is a classic solution for Git hosting via SSH. It offers granular permission control but lacks a web UI. Ideal for power users who are comfortable with command-line configuration and want ultimate automation and scripting flexibility.


Conclusion

Hosting your own Git server with Gitea offers privacy, flexibility, and a learning journey that scales from lone developers to small teams. With its intuitive interface and rapid deployment capabilities, Gitea is an excellent choice. For teams wanting even more control and are comfortable on the terminal, Gitolite is worth a look.

Whether you’re a hobbyist, professional, or small company, running your own Git server means your code stays yours, always.


Resources:


Happy coding and hosting!