SimpleGit is a lightweight, self-hosted Git server written in Go that provides a clean web interface for browsing repositories and Git operations over HTTP and SSH protocols.
-
Web Interface
- Repository browser with syntax highlighting
- Commit history viewer
- File content viewer with symbol navigation
- Support for multiple branches
- Admin dashboard
- Dark theme with Nord color scheme
-
Git Operations
- HTTP Git protocol support (clone, push, pull)
- SSH Git protocol support
- User-managed SSH key authentication
- Support for bare repositories
-
User Management
- User authentication with JWT
- Role-based access control (Admin/User)
- SSH key management per user
- Admin user creation system
-
Technical Features
- SQLite database for user management
- Docker and Docker Compose support
- Configurable through environment variables or JSON
- Syntax highlighting for multiple languages
- Symbol detection and navigation for code files
- Install Go 1.21 or later
- Clone the repository:
git clone https://github.com/yourusername/simplegit.git
cd simplegit
- Create the configuration file:
cp config.json.example config.json
-
Edit
config.json
with your settings -
Build and run:
go build
./simplegit
The server can be configured through environment variables or a JSON config file. Environment variables take precedence over the JSON configuration.
Environment variables:
SIMPLEGIT_DEV_MODE
: Enable development mode (boolean)SIMPLEGIT_PORT
: HTTP server portSIMPLEGIT_SSH_PORT
: SSH server port (default: 2222)SIMPLEGIT_DATE_FORMAT
: Date format stringSIMPLEGIT_MAX_FILE_SIZE
: Maximum file size for web display in bytesSIMPLEGIT_DATA_DIR
: Directory for database and data storageSIMPLEGIT_JWT_SECRET
: Secret key for JWT tokensSIMPLEGIT_DOMAIN
: Server domain name (default: localhost)SIMPLEGIT_SSH_KEY_PATH
: Path to SSH host keySIMPLEGIT_REPO_PATH
: Path to store Git repositoriesSIMPLEGIT_DB_PATH
: Path to SQLite database file
The included Docker setup provides:
- Multi-stage build for minimal image size
- Volume mounting for repositories and data
- Environment-based configuration
- Automatic repository directory creation
- Non-root user for security
Example docker-compose.yml:
version: "3.8"
services:
simplegit:
build: .
ports:
- "3000:3000"
- "2222:2222"
volumes:
- ./repositories:/app/repositories
- ./data:/app/data
environment:
- SIMPLEGIT_PORT=3000
- SIMPLEGIT_SSH_PORT=2222
- SIMPLEGIT_JWT_SECRET=your-secure-secret
- SIMPLEGIT_DOMAIN=git.yourdomain.com
- SIMPLEGIT_MAX_FILE_SIZE=10485760
restart: unless-stopped
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
Custom Docker run command:
docker run -d \
--name simplegit \
-p 3000:3000 \
-p 2222:2222 \
-v ./repositories:/app/repositories \
-v ./data:/app/data \
-e SIMPLEGIT_PORT=3000 \
-e SIMPLEGIT_SSH_PORT=2222 \
-e SIMPLEGIT_JWT_SECRET=your-secure-secret \
-e SIMPLEGIT_DOMAIN=localhost \
-e SIMPLEGIT_DATA_DIR=/app/data \
-e SIMPLEGIT_REPO_PATH=/app/repositories \
-e SIMPLEGIT_DB_PATH=/app/data/githost.db \
simplegit
- Start the server for the first time
- Look for the admin setup token in the console output
- Visit http://localhost:3000/setup-admin
- Use the setup token to create the admin account
- Log in with the admin account
- Create repositories and users through the admin interface
- Log in as admin
- Go to Admin → Repositories
- Click "Create Repository"
- Enter repository name and description
HTTP:
git clone http://localhost:3000/repo/example.git
SSH:
git clone ssh://git@localhost:2222/example.git
simplegit/
├── config/ # Configuration handling
├── database/ # Database initialization
├── handlers/ # HTTP request handlers
├── models/ # Data models and business logic
├── ssh/ # SSH server implementation
├── static/ # Static web assets
├── templates/ # HTML templates
└── utils/ # Utility functions
-
Backend:
- Go 1.21+
- go-git (Git operations)
- GORM (ORM)
- SQLite (Database)
- Gorilla Mux (Routing)
- JWT (Authentication)
-
Frontend:
- HTMX (Dynamic updates)
- Highlight.js (Syntax highlighting)
- Font Awesome (Icons)
- Nord theme (Color scheme)
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is released under the Unlicense. See the LICENSE file for details.
Built with these excellent libraries:
- highlight.js - BSD Three Clause License
- htmx - BSD Zero Clause License
- go-git - Apache License 2.0