gitrub
Local GitHub replacement. Push, pull, clone over HTTP and SSH. Supports LFS, shallow/partial clones, protocol v2, server-side hooks, and archive downloads.
Install
cargo install gitrub
Or build from source:
cargo build --release
Run
gitrub [OPTIONS]
Options:
--root <DIR> Repository root (default: ./repos)
--host <ADDR> Bind address (default: 0.0.0.0)
--port <PORT> HTTP port (default: 3000)
--ssh-port <PORT> SSH port (default: 2222)
--user <USER> Username for auth
--pass <PASS> Password for auth
--noauth Skip auth
--hooks-dir <DIR> Copy hooks into new repos
--no-ssh Disable SSH server
--recursive List repos recursively (include nested paths)
Examples
# No auth, defaults
# With auth
# Custom ports + hooks
Usage
# HTTP
# SSH
# Shallow clone
# Partial clone (blobless)
# Download archive
# Switch from GitHub (replace origin)
# Keep GitHub as primary, add gitrub as secondary
# Push to both at once
Repos auto-create on first push. Any path depth works.
Using alongside GitHub
Most users keep GitHub as their primary remote. Here's how to add gitrub as a secondary backup or local mirror:
Option 1: Separate remote (recommended)
Add gitrub as a named remote alongside origin:
# Your repo already has GitHub as origin
# origin git@github.com:user/project.git (fetch)
# origin git@github.com:user/project.git (push)
# Add gitrub as a second remote called "local"
# Push to gitrub
# Push all branches + tags
# Pull still defaults to GitHub
Option 2: Push to both at once
Configure origin to push to GitHub and gitrub simultaneously:
# Add gitrub as an additional push URL on origin
# Now every push goes to both
# Verify
# origin git@github.com:user/project.git (fetch)
# origin git@github.com:user/project.git (push)
# origin http://localhost:3000/user/project.git (push)
Note: Fetch still pulls from GitHub only. This is usually what you want — GitHub is the source of truth, gitrub is a local backup.
Mirror an existing GitHub repo
# Clone from GitHub, then push everything to gitrub
Features
| Feature | Status |
|---|---|
| Push / Pull / Clone | ✅ HTTP + SSH |
| Branches & Tags | ✅ |
| Force push / Delete branch | ✅ |
| Git Protocol v2 | ✅ |
Shallow clones (--depth) |
✅ |
Partial clones (--filter) |
✅ |
| Git LFS | ✅ Batch API + basic transfer |
| SSH transport | ✅ Built-in server (Ed25519) |
| Archive download | ✅ tar, tar.gz, zip |
| Server-side hooks | ✅ --hooks-dir |
| HTTP Basic auth | ✅ |
| Auto-create repos on push | ✅ |
Nested paths (org/team/repo) |
✅ |
| Activity tracking | ✅ Last push/pull timestamps |
| Repo detail view | ✅ Commits, files, branches |
| Recursive repo listing | ✅ --recursive flag |
TUI Keybindings
| Key | Action |
|---|---|
↑/↓ |
Navigate repos or settings |
Tab |
Switch focus (settings ↔ repos) |
Enter |
Open repo detail view / edit setting |
c |
Open command palette for selected repo |
/ |
Search / filter repos |
s |
Start / stop server |
r |
Refresh repo list |
q |
Quit |
Repo Detail View
| Key | Action |
|---|---|
Tab |
Switch tab (Commits → Files → Branches) |
↑/↓ |
Scroll |
PgUp/PgDn |
Scroll by page |
c |
Open command palette |
r |
Refresh detail data |
Esc |
Close detail view |
Server-side hooks
Create a hooks directory with executable scripts:
Hooks are copied into each new repo's hooks/ directory. Supported hooks: pre-receive, post-receive, update, and any other git hook.
LFS
gitrub implements the Git LFS Batch API. Configure your repo to use it:
LFS objects are stored under <root>/<repo>/lfs/objects/.
Test
cargo test
28 integration tests covering push, pull, clone, branches, tags, force push, branch deletion, auth, shallow clones, partial clones, protocol v2, archive, hooks, and LFS.
Author
License
MIT — see LICENSE for details.