Skip to main content
wit includes a built-in Git server that accepts push and pull over HTTP. Run your own GitHub-like infrastructure with a single command.

Quick Start

# Start the server
wit serve

# Server is now running at http://localhost:3000

Command Reference

wit serve [options]
OptionDescriptionDefault
--port <number>Port to listen on3000
--repos <path>Directory to store repositories./repos
--host <hostname>Hostname to bind to0.0.0.0
--verboseEnable verbose loggingfalse
-h, --helpShow help message-

Examples

Basic Usage

# Start on default port 3000
wit serve

# Start on a different port
wit serve --port 8080

# Custom repository directory
wit serve --repos /var/git/repositories

# Verbose logging for debugging
wit serve --verbose

Production Setup

# Full production configuration
wit serve \
  --port 3000 \
  --repos /var/git/repos \
  --host 0.0.0.0

Using the Server

Once the server is running, you can interact with it using standard git commands.

Clone a Repository

wit clone http://localhost:3000/owner/repo.git

Push to Create a New Repository

Repositories are created automatically on first push:
# Initialize a local repository
wit init my-project
cd my-project
echo "# My Project" > README.md
wit add .
wit commit -m "Initial commit"

# Add remote and push (creates repo on server)
wit remote add origin http://localhost:3000/myuser/my-project.git
wit push -u origin main

Fetch and Pull

wit fetch origin
wit pull origin main

Server Output

When you start the server, you’ll see:
╔══════════════════════════════════════════════════════════════╗
║                                                              ║
║   🚀 wit server is running!                                  ║
║                                                              ║
║   HTTP URL: http://localhost:3000                            ║
║   tRPC API: http://localhost:3000/trpc                       ║
║   Repositories: /path/to/repos                               ║
║                                                              ║
║   Clone: wit clone http://localhost:3000/owner/repo.git      ║
║   Push:  wit push origin main                                ║
║                                                              ║
║   Press Ctrl+C to stop                                       ║
║                                                              ║
╚══════════════════════════════════════════════════════════════╝

Existing repositories:
  - alice/project-a
  - bob/project-b

API Endpoints

The server exposes several endpoints:
EndpointDescription
GET /healthHealth check with database status
GET /reposList all repositories
POST /syncSync filesystem repos to database
/trpc/*tRPC API endpoints
/:owner/:repo.git/*Git Smart HTTP protocol

Health Check

curl http://localhost:3000/health
Response:
{
  "status": "ok",
  "version": "2.0.0",
  "timestamp": "2024-01-15T10:30:00.000Z",
  "database": {
    "connected": true,
    "latency": 5
  }
}

List Repositories

curl http://localhost:3000/repos
Response:
{
  "count": 2,
  "repositories": [
    { "owner": "alice", "name": "project-a", "url": "/alice/project-a.git" },
    { "owner": "bob", "name": "project-b", "url": "/bob/project-b.git" }
  ]
}

Database Integration

For full platform features (users, PRs, issues), connect to PostgreSQL:
# Set database URL
export DATABASE_URL="postgresql://user:password@localhost:5432/wit"

# Start server - it will connect to the database
wit serve --port 3000 --repos ./repos
Without a database, the server works for basic Git operations but won’t have:
  • User accounts
  • Pull requests
  • Issues
  • Activity tracking

Repository Storage

Repositories are stored as bare Git repositories:
repos/
├── alice/
│   └── project-a.git/
│       ├── HEAD
│       ├── config
│       ├── objects/
│       └── refs/
└── bob/
    └── project-b.git/

Running in Docker

FROM node:22-alpine

WORKDIR /app
COPY . .
RUN npm install && npm run build

EXPOSE 3000
VOLUME /repos

CMD ["node", "dist/cli.js", "serve", "--repos", "/repos"]
docker build -t wit-server .
docker run -p 3000:3000 -v ./my-repos:/repos wit-server

Using with docker-compose

version: '3.8'

services:
  wit:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - ./repos:/repos
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@db:5432/wit
    depends_on:
      - db

  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: wit
      POSTGRES_PASSWORD: postgres
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Graceful Shutdown

The server handles shutdown signals gracefully:
# Ctrl+C or kill signal
Shutting down server...
[server] Server stopped
This ensures in-progress operations complete before shutdown.

Troubleshooting

# Find what's using the port
lsof -i :3000

# Use a different port
wit serve --port 3001
# Create directory with correct permissions
mkdir -p ./repos
chmod 755 ./repos
Check your DATABASE_URL environment variable:
echo $DATABASE_URL
# Should be: postgresql://user:pass@host:port/dbname
The server will continue without database features if connection fails.
Make sure the repository URL matches the pattern:
http://localhost:3000/{owner}/{repo}.git
The owner and repo will be extracted from the URL.

Next Steps