A pure Python implementation of a Git Smart HTTP server with no run dependencies. Developed and maintained using Google AI Studio.
- Smart HTTP protocol support (
git-upload-pack,git-receive-pack) - Native IPv6 and Dual-stack IPv4/IPv6 support
- Auto-creation of repositories for trusted hosts
- Push support for trusted hosts
- Simple HTTP server for non-smart requests
- Configurable via CLI
You can build the wheel using the provided pyproject.toml:
python3 -m pip install build
python3 -m build
pip install dist/*.whlStart the server with default settings (port 3000, repos in ./repos):
# Using the module
PYTHONPATH=src python3 -m git_smart_http
# If installed via pip
git-smart-httprepo_dir: Positional argument for the directory to store repositories (default: repos).-p,--port: Port to bind to (default: 3000).-v,--verbose: Increase console verbosity (can be used multiple times).-l,--logfile: Enable logging to a file (file log level is always fixed at INFO).-t,--trusted-host: Add a trusted host IP (can be used multiple times).-b,--browser: Open the server URL in the default web browser.--version: Show the version number and exit.
The server supports both IPv4 and IPv6. A trusted host is an IP address explicitly allowed to perform write operations (pushing and auto-creating repositories) via the -t or --trusted-host CLI option. By default, only 127.0.0.1 (IPv4 loopback) and ::1 (IPv6 loopback) are trusted if no other hosts are specified.
Creating a new repository: If the host is trusted, cloning a non-existent repository will auto-create it.
Using IPv4:
git clone http://127.0.0.1:3000/my-new-repo.gitUsing IPv6:
git clone http://[::1]:3000/my-new-repo.gitCloning:
- Read-Write Access (Trusted Host):
Cloning from a trusted host allows full smart HTTP protocol support, including pushing back to the server.
git clone http://127.0.0.1:3000/repo.git # or for IPv6 git clone http://[::1]:3000/repo.git - Read-Only Access (Untrusted Host):
Untrusted hosts can still clone existing repositories but cannot push or trigger auto-creation.
# Assuming the server is running on 192.168.1.50 and this host is not trusted git clone http://192.168.1.50:3000/repo.git
Pushing: Pushing is only allowed from trusted hosts.
git push origin mainListing Repositories:
Open http://127.0.0.1:3000/ in your browser to see the list of repositories using the built-in simple HTTP server.
This project was built using Google AI Studio. To run tests:
PYTHONPATH=src python3 -m pytest tests/test_server.py tests/test_ipv6.py