← Volver al blog

How to Set Up a Git Server on VPS

  • Xernode
  • 1 min de lectura
  • 9 de abril de 2026
VPS linux vps git git-server version-control repository

Introduction

Hosting your own Git server on a VPS gives you full control over your code repositories. This guide shows you how to set up a basic Git server using SSH on Linux.

Step-by-step Guide

  1. Update your package list
    • sudo apt update
  2. Install Git
    • sudo apt install -y git
  3. Create a new user for Git access
    • sudo adduser git
  4. Switch to the git user
    • sudo su - git
  5. Create a bare repository
    • mkdir ~/myproject.git
    • cd ~/myproject.git
    • git init --bare
  6. Exit back to your main user
    • exit
  7. On your local machine, add the remote repository
    • git remote add origin git@your_server_ip:~/myproject.git
  8. Push your code
    • git push -u origin master

Recommendations

  • Use SSH keys for secure authentication.
  • Regularly backup your repositories.
  • Consider using Gitea or GitLab for a web interface and advanced features.

Call To Action

eed a reliable VPS for your Git repositories? Check out our hosting plans: https://xernode.com/#pricing

Related Guides