If you want to host a private Git repository on infrastructure you control, you have more options than you might think. Whether you are a solo developer or a growing team, this guide covers two proven approaches, access control, and backup best practices.
Why Host a Private Git Repository?
Hosting a private Git repository on your own server gives your team full control over source code, data residency, and access policies. It also removes dependency on third-party uptime and pricing decisions — a key concern for fintech, iGaming, and regulated industries. For teams already running on managed VPS infrastructure, the overhead is minimal. See our VPS hosting guide for recommended specifications before you start.
Two Approaches to Host a Private Git Repository
Option 1: Bare Git over SSH
The lightest way to host a private Git repository requires only Git installed on a Linux server and SSH access. There is no web interface, but the setup takes minutes and suits solo developers or micro-teams.
Basic setup steps:
- Install Git on your server:
sudo apt install git -y - Create a dedicated user:
sudo adduser --system --shell /bin/bash git - Initialise a bare repository:
git init --bare /home/git/project.git - Push from your workstation:
git remote add origin git@yourserver:/home/git/project.git
This approach has the smallest attack surface and the lowest maintenance overhead.
Option 2: Gitea (Lightweight Web UI)
Gitea is the recommended way to host a private Git repository when your team needs pull requests, issue tracking, and user management. Written in Go, it runs on as little as 512 MB RAM and installs via a single binary or Docker.
Basic setup steps:
- Install PostgreSQL and Nginx:
sudo apt install postgresql nginx -y - Download the Gitea binary from gitea.io and place it in
/usr/local/bin/gitea - Create a systemd service and run
sudo systemctl enable --now gitea - Obtain a TLS certificate with Certbot:
sudo certbot --nginx -dgit.yourdomain.comreplace with your actual domain, then configure Nginx to proxy requests tolocalhost:3000 - Open
https://git.yourdomain.comreplace with your actual domain in your browser to complete the web installation
For teams that outgrow Gitea, GitLab Community Edition offers full CI/CD pipelines and a container registry, though it requires a minimum of 4 GB RAM.
Access Control and SSH Keys
Regardless of which approach you choose to host a private Git repository, SSH key authentication is the standard access method. It is more secure than passwords because there is nothing to intercept or brute-force.
Generate a key pair on a developer workstation:
bash
ssh-keygen -t ed25519 -C "[email protected]"
For bare Git, add the public key to ~/.ssh/authorized_keys on the server. For Gitea, developers upload their public key via the web interface.
Disable password-based SSH immediately after setup. Edit /etc/ssh/sshd_config:
PasswordAuthentication no
ChallengeResponseAuthentication no
Reload the SSH service to apply. This single change eliminates the majority of brute-force exposure. For further hardening guidance, the Mozilla SSH Guidelines provide a well-maintained reference.
Gitea also supports repository-level permissions, organisations, and LDAP/SAML integration — essential for teams that manage access through an existing identity provider. See our LDAP integration walkthrough for step-by-step configuration.
Backup and Maintenance
When you host a private Git repository, you are responsible for your own backups. Run automated nightly backups and store them off-site.
- Gitea: Use the admin panel backup command or script a direct filesystem backup of the data directory alongside a PostgreSQL dump.
- Bare Git: A nightly
rsyncof the repository directory to an off-site location is sufficient.
Monitor disk usage closely — a full disk is the most common and most preventable cause of Git server outages. For production-grade reliability, see our [managed VPS plans → /VPS for hosting environments with SSD storage and 24/7 support.
Comparison Table: Git Server Options
The table below summarises the key differences between the most common self-hosted Git server approaches. Use it to match your team size and requirements to the right platform.
| Feature | Bare Git + SSH | Gitea | GitLab CE | Forgejo | Gogs | Key Benefit |
| Web Interface | None | Yes | Yes | Yes | Yes | Visual repo management |
| Pull Requests | No | Yes | Yes | Yes | Yes | Code review workflow |
| Built-in CI/CD | No | Basic (Actions) | Full pipeline | Basic (Actions) | No | Automation |
| Min RAM | 256 MB | 512 MB | 4 GB | 512 MB | 256 MB | Resource planning |
| Install Complexity | Low | Low | High | Low | Low | Team readiness |
| Container Registry | No | No | Yes | No | No | Docker/OCI support |
| LDAP / SSO | No | Yes | Yes | Yes | Limited | Enterprise auth |
| Best For | Solo / micro teams | Small to mid teams | Enterprise teams | Privacy-focused teams | Minimal setups | Scenario guide |
| License | Open Source | MIT | MIT (CE) | GPL-3.0 | MIT | Compliance check |
Frequently Asked Questions
No. Git is a distributed system, so every developer already has a full copy of the repository. You add the new server as a remote, push all branches and tags, and then update your team’s remote URL. The migration can happen with zero data loss and minimal downtime.
The software itself is free for all three options covered here. Your main cost is infrastructure. A Gitea instance for a small team can run on a VPS costing less than ten dollars per month. GitLab CE for an enterprise team may require a dedicated server or a cluster, which increases cost considerably. Contrast this with per-seat pricing on hosted platforms as your team grows.
Yes. Gitea supports Gitea Actions, which uses a syntax compatible with GitHub Actions. Alternatively, you can connect any self-hosted Git server to external CI tools such as Jenkins, Drone CI, or Woodpecker CI via webhooks. GitLab CE includes a full CI/CD pipeline engine out of the box.
The primary risks are operational. You are responsible for uptime, patching, backups, and incident response. A hosted platform abstracts these concerns away. To manage this risk, use a reliable hosting provider, automate your backups, and document your runbooks so that any team member can respond to an incident.
Both Gitea and GitLab CE support granular access controls. You can create organisations, teams, and projects and assign read, write, or admin permissions at the repository level. Integration with LDAP or SAML allows you to manage permissions through your existing identity provider rather than maintaining separate user accounts.
Get Started with Reliable Hosting for Your Git Server
Running your own Git server requires a stable, secure hosting environment. HostingB2B provides VPS and dedicated server solutions built for teams that need control over their infrastructure. From fast SSD storage to managed backups and 24/7 support, the platform gives you the foundation your Git server needs to stay online and performant.
Visit HostingB2B VPS plans to find the right fit for your team. For larger deployments, explore dedicated server options. Whether you are setting up Gitea for a startup or deploying GitLab CE for an enterprise engineering team, HostingB2B has the infrastructure to support it.
Conclusion
Two solid paths exist when you want to host a private Git repository: bare Git over SSH for minimal setups, and Gitea for teams that need a full web interface. In both cases, disable password authentication, enable HTTPS, and automate your backups from day one.
