Skip to content

instaweb Git Command Guide

The git instaweb command automatically launches a web server to view Git repositories through a web browser, providing instant web interface for repository exploration without complex configuration.

Terminal window
git instaweb [start] [-l|--local] [-d|--httpd|--module-path|--cgi-bin|--document-root|
--server|--port|--browser|--stop|--restart]
[--<httpd-daemon-options>]
SubcommandDescription
startStart web server (default)
stopStop running web server
restartRestart web server
OptionDescription
--localBind to 127.0.0.1 only
--httpd=<server>Web server to use
--port=<port>Port to listen on
--browser=<browser>Browser to launch
--module-path=<path>CGI module path
--cgi-bin=<path>CGI bin directory
--document-root=<path>Document root path
Terminal window
# Use Lighttpd for serving
git instaweb --httpd=lighttpd --port=1234
# Custom Lighttpd configuration
git instaweb --httpd=lighttpd \
--module-path=/usr/share/gitweb \
--port=8080
Terminal window
# Use Apache with custom paths
git instaweb --httpd=apache2 \
--cgi-bin=/usr/lib/cgi-bin \
--document-root=/var/www
Terminal window
# Use WEBrick (fallback option)
git instaweb --httpd=webrick --port=3000
Terminal window
# Use nginx with fcgiwrap
git instaweb --httpd=nginx \
--cgi-bin=/usr/lib/cgi-bin \
--port=80
Terminal window
# Start default web server and browser
git instaweb
# Start with specific port
git instaweb --port=8080
# Bind to localhost only
git instaweb --local
Terminal window
# Specify browser explicitly
git instaweb --browser=firefox
# Use custom browser command
git instaweb --browser="google-chrome --incognito"
Terminal window
# Stop running server
git instaweb stop
# Restart server
git instaweb restart
# Check server status
ps aux | grep -E "(lighttpd|apache|webrick)" | grep -v grep
Terminal window
# Complete setup for public access
git instaweb --httpd=lighttpd \
--port=80 \
--cgi-bin=/var/www/cgi-bin \
--module-path=/usr/share/gitweb \
--browser=none # Don't auto-launch browser
# Access URL displayed in terminal
Terminal window
# Different repos on different ports
cd project1 && git instaweb --port=3001 --local
cd ../project2 && git instaweb --port=3002 --local
# Access both via browser
# http://localhost:3001
# http://localhost:3002
Terminal window
# Configure custom gitweb appearance
git config instaweb.gitwebConfig "$(cat <<EOF
our \$site_name = 'My Project';
our \$site_html_head_string = '<style>body { font-family: Arial; }</style>';
EOF
)"
Terminal window
# Serve custom static files
cp custom.css /tmp/gitweb-static/
cp logo.png /tmp/gitweb-static/
git instaweb --document-root=/tmp/gitweb-static
Terminal window
# Detect and launch default browser
git instaweb # Opens http://localhost:1234 or similar
# Specify browser in config
git config web.browser firefox
git instaweb # Uses firefox
# Disable auto-launch
git instaweb --browser=none
Terminal window
# Browser-specific configurations
export BROWSER=chromium-browser
git instaweb
# Windows-style paths (on Windows)
git instaweb --browser="C:\Program Files\Mozilla Firefox\firefox.exe"
Terminal window
# Local-only access for development
git instaweb --local
# Public access with care
git instaweb --port=80 # Requires proper permissions
Terminal window
# Cleanup orphaned processes
pkill -f "gitweb.cgi|lighttpd.*gitweb"
# Check running servers
netstat -tlnp | grep :1234 || echo "No server running"
Terminal window
# Allow local access
ufw allow from 127.0.0.1 to any port 1234
# Corporate environment setup
git instaweb --local # Ensures no external access
Terminal window
# Check available servers
which lighttpd || which apache2 || which ruby
# Manual server verification
lighttpd -v || apache2 -v || ruby -v
# Debug mode
GIT_INSTAWEB_DEBUG=1 git instaweb
Terminal window
# Fix CGI script permissions
chmod +x /usr/share/gitweb/gitweb.cgi
# Directory write permissions
sudo chown -R www-data:www-data /tmp/gitweb-*
# SELinux/AppArmor issues
sudo setsebool -P httpd_enable_cgi 1
Terminal window
# Override BROWSER variable
BROWSER=xdg-open git instaweb
# Test browser launch separately
xdg-open http://localhost:1234
# Browser not found errors
export BROWSER=chromium-browser
Terminal window
# Find available port
netstat -tlnp | grep -E ":([0-9]{4})" | awk -F: '{print $2}' | sort | tail
# Use random port
git instaweb # Uses available port
Terminal window
# Verify gitweb installation
ls -la /usr/share/gitweb/
ls -la /usr/lib/cgi-bin/gitweb.cgi
# Custom path configuration
git instaweb --module-path=/custom/gitweb/path
Terminal window
# Quick repository visualization
cd myproject && git instaweb --local --port=3000
# Show to colleagues
echo "View at: http://my-machine:3000"
# Stop when done
git instaweb stop
Terminal window
# Present repository to team
git instaweb --httpd=lighttpd --port=8080
# Navigate to specific commits
# Review changes visually through web interface
# Pull latest changes and refresh
git pull origin main # Web interface auto-updates
Terminal window
# Demonstrate Git workflows visually
git instaweb
# Walk through:
# - Commit history browsing
# - File content viewing
# - Search functionality
# - Project documentation access
Terminal window
# Present project repository
git instaweb --browser=firefox --port=80
# Include README in web interface
git add README.md && git commit -m "Add documentation"
# README visible in web interface
# Programmatic server management
#!/bin/bash
git instaweb --port=3001 --local --browser=none &
SERVER_PID=$!
echo "Server started with PID: $SERVER_PID"
# Run tests, then cleanup
cleanup() {
kill $SERVER_PID 2>/dev/null || true
git instaweb stop 2>/dev/null || true
}
trap cleanup EXIT
# Integration tests here
curl -f http://localhost:3001/ || exit 1
Terminal window
# Launch from IDE terminal
# VS Code or other IDEs can open browser automatically
git instaweb --browser=none
code --open-url http://localhost:1234
Terminal window
# Full-screen browser for presentations
git instaweb --browser="chromium-browser --start-fullscreen"
# Test gitweb interface programmatically
#!/bin/bash
git instaweb --local --port=3000 --browser=none &
sleep 2
# Test endpoints
curl -s http://localhost:3000/ | grep -q "gitweb" && echo "Gitweb interface working"
git instaweb stop

gitweb requires manual server configuration; instaweb automates setup with local mini-server. gitweb is permanent, instaweb is temporary for development/testing.

By default serves single repository. Start multiple instances on different ports or configure centralized gitweb instance.

What happens if preferred web server unavailable?

Section titled “What happens if preferred web server unavailable?”

Falls back to available servers in order: lighttpd, apache, webrick. Use —httpd to specify preference.

How do I customize gitweb appearance through instaweb?

Section titled “How do I customize gitweb appearance through instaweb?”

Configure gitweb settings in gitweb.conf or via git config anima trial. Preview changes with instaweb before permanent gitweb deployment.

Can instaweb be used in production environments?

Section titled “Can instaweb be used in production environments?”

Not recommended - temporary solution only. Use proper web server setup with authentication, SSL, and monitoring for production.

How do I access instaweb from different machines?

Section titled “How do I access instaweb from different machines?”

Remove —local flag and configure firewall. But seriously consider security implications and use VPN if needed.

What browsers are supported for auto-launch?

Section titled “What browsers are supported for auto-launch?”

Any browser in PATH or detected via xdg-open (Linux/BSD), open (macOS), start (Windows). Configurable via BROWSER environment variable.

How do I troubleshoot server startup failures?

Section titled “How do I troubleshoot server startup failures?”

Check permissions, port availability, required packages. Try different —httpd options. Use strace or similar to debug startup process.

Yes, works with both bare and non-bare repositories. Bare repositories show cloned state, perfect for server-side viewing.

What’s the performance impact of running instaweb?

Section titled “What’s the performance impact of running instaweb?”

Lightweight for development, but each access requires CGI process spawn. Consider pre-forking for heavy usage, but primarily for temporary viewing.

How do I integrate instaweb with CI/CD pipelines?

Section titled “How do I integrate instaweb with CI/CD pipelines?”

Possible but unusual - better to use gitweb or cgit for permanent interfaces. instaweb better for development/preview stages.

Yes, copy CSS files to served static directory and configure gitweb to use custom stylesheets.

What’s the difference between instaweb ports?

Section titled “What’s the difference between instaweb ports?”

Random port assignment avoids conflicts. Use —port for specific port. Different projects can run on different ports simultaneously.

Use —browser=none flag to suppress automatic browser opening, useful for remote access or scripted usage.

  1. Development Visualization: Quick web interface for exploring repository during development
  2. Team Sharing: Temporary repository access for colleagues during code reviews
  3. Presentation Tools: Visual Git demonstration for training and educational purposes
  4. Project Showcases: Simple web presence for project repositories and documentation
  5. Integrated Development: Repository visualization integrated with development workflows
  6. Quick Repository Access: Instant web interface without complex configuration or installation