wit serve command starts a Git HTTP server for hosting repositories. For a complete platform setup including database and web UI, use wit up instead.
Overview
Options
| Option | Description |
|---|---|
--port <number> | Port to listen on (default: 3000) |
--repos <path> | Directory to store repositories (default: ./repos) |
--host <hostname> | Hostname to bind to (default: 0.0.0.0) |
--verbose | Enable verbose logging |
-h, --help | Show help message |
Examples
Example Output
Environment Variables
| Variable | Description | Default |
|---|---|---|
PORT | Server port | 3000 |
REPOS_DIR | Repository storage directory | ./repos |
HOST | Hostname to bind | 0.0.0.0 |
DATABASE_URL | PostgreSQL connection string | Required |
BETTER_AUTH_SECRET | Auth secret (production) | Required in prod |
What wit serve Provides
The server exposes:Git HTTP Protocol
- Clone:
wit clone http://localhost:3000/owner/repo.git - Push:
wit push origin main - Fetch:
wit fetch origin
REST API
- Repository management
- User authentication
- Pull request operations
tRPC API
- Full platform functionality
- Real-time updates
- Type-safe client access
Use Cases
Development Server
Run a local server for development:CI/CD Integration
Use as a Git server in CI pipelines:Self-Hosted Git Server
Run a persistent Git server:wit serve vs wit up
| Feature | wit serve | wit up |
|---|---|---|
| API Server | Yes | Yes |
| Database | External only | Auto-starts PostgreSQL |
| Web UI | No | Yes |
| Migrations | Manual | Automatic |
| Background | Foreground | Daemonized |
| Use case | Production, custom setup | Development, quick start |
wit serve when:
- You have an external database
- You only need the API server
- You’re deploying to production with custom orchestration
wit up when:
- You want everything started automatically
- You’re developing locally
- You need the web UI
Graceful Shutdown
The server handles shutdown signals properly:- In-flight requests complete
- Database connections close cleanly
- Resources are released
Troubleshooting
Port already in use
Port already in use
Database connection failed
Database connection failed
DATABASE_URL is set and the database is running:Permission denied on repos directory
Permission denied on repos directory