Build My Own Git (Git Server)
· 2025Self-hosted Git server on AWS EC2 with SSH access and GitWeb UI.
gitserversshawslinux

Description
This project demonstrates how to set up a self-hosted Git server using an AWS EC2 instance. It covers installing Git, enabling secure SSH access for developers, creating bare repositories, pushing/pulling from multiple machines, and adding a web-based repository browser via GitWeb.
Audience: Developers and teams who want to self-host version control and learn Git internals.
Problem Statement
How to set up a secure, lightweight, self-hosted Git server for multi-user collaboration with both CLI and web UI access.
Features / Highlights
- Launch and configure an AWS EC2 instance for hosting Git
- Create a dedicated 'git' user and manage SSH access
- Initialize bare repositories under /var/lib/git
- Add developer public SSH keys for secure access
- Push and pull code from multiple machines over SSH
- Install and configure GitWeb for a simple web UI (e.g., port 1234)
- Understand Git internals (.git/objects, refs, HEAD and blob storage)
Tech Stack
GitLinuxOpenSSHGitWebAWS EC2
Use Cases
- Practice setting up your own version control infrastructure
- Use as a lightweight private Git alternative
- Educational deep-dive into Git internals and SSH
Screenshots / Demo




Architecture & Workflow
EC2 host exposes SSH for developers; repositories stored as bare repos; GitWeb provides read-only browsing.

Challenges & Learnings
Learnings
- How to launch and configure an AWS EC2 instance
- Creating a 'git' user and managing SSH access
- Initializing bare Git repositories manually
- Handling secure access with SSH public keys
- Serving repositories via GitWeb on a custom port
- Repository structure: objects, refs, HEAD
- How Git stores files as compressed blobs
Quick Q&A
How to Use / Installation
- Provision an EC2 instance (Ubuntu/Debian). Open port 22 (SSH) and optional web port (e.g., 1234).
- SSH in and install packages: sudo apt update && sudo apt install -y git gitweb
- Create git user: sudo adduser git
- Create repo root: sudo mkdir -p /var/lib/git && sudo chown -R git:git /var/lib/git
- As git user, create bare repo: cd /var/lib/git && git init --bare my-project.git
- Add developer SSH keys to /home/git/.ssh/authorized_keys
- Optionally run GitWeb (configure GITWEB_PROJECTROOT=/var/lib/git and serve on your chosen port).
- Clone from clients: git clone git@<ec2-ip>:/var/lib/git/my-project.git
Your Role & Contributions
Solo builder
- EC2 provisioning and server hardening
- SSH user management and key-based auth setup
- Bare repository initialization and workflows
- GitWeb configuration and documentation