LinuxCommandLibrary

git-instaweb

Browse Git repository in web browser

TLDR

Launch a GitWeb server for the current Git repository

$ git instaweb --start
copy

Listen only on localhost
$ git instaweb --start [[-l|--local]]
copy

Listen on a specific port
$ git instaweb --start [[-p|--port]] [1234]
copy

Use a specified HTTP daemon
$ git instaweb --start [[-d|--httpd]] [lighttpd|apache2|mongoose|plackup|webrick]
copy

Also auto-launch a web browser
$ git instaweb --start [[-b|--browser]]
copy

Stop the currently running GitWeb server
$ git instaweb --stop
copy

Restart the currently running GitWeb server
$ git instaweb --restart
copy

SYNOPSIS

git instaweb [--http|--https] [--port <number>] [--ip <address>] [--start|--stop|--restart] [--browser <browser>] [--local]

PARAMETERS

--http
    Use HTTP protocol (default)

--https
    Use HTTPS protocol (requires SSL keys in temp dir)

--port <number>
    Port to bind (default: 1234)

--ip <address>
    IP address to bind (default: all interfaces)

--start
    Start the web server (default action)

--stop
    Stop a running instaweb server

--restart
    Restart a running instaweb server

--browser <browser>
    Browser command to launch (default: auto-detect)

--local
    Bind only to localhost (overrides --ip)

DESCRIPTION

git instaweb is a Git porcelain command that quickly starts a lightweight web server to browse the current working repository via a web interface, typically Gitweb. It automatically detects and uses available web servers like lighttpd (preferred default), Apache, Ruby's WEBrick, or Mongoose, configuring them on-the-fly without permanent setup.

Ideal for developers needing instant local or shareable access to repo contents—view commits, diffs, trees, blobs, and logs—without cloning or full Gitweb installation. On start, it binds to a port (default 1234), launches the specified or detected browser, and serves at http://localhost:1234 (or bound IP). Supports HTTP/HTTPS, custom ports/IPs, and control actions like stop/restart.

The server runs in the foreground by default but can be backgrounded. It respects Gitweb config from gitweb_config.perl if present. Cleanup is automatic on stop, removing temp files. Perfect for quick demos, debugging, or team shares during development sessions.

CAVEATS

Requires supported web server (lighttpd recommended, install if missing). Not for production; single-user, temp setup only. Runs as current user—limited permissions. HTTPS needs manual SSL certs. Cleans temp files on stop, but check for leftovers.

WEB SERVER PRIORITY

Tries lighttpd > Apache > mongoose > plackup > webrick. Override with GIT_INSTAWEB_WEBSERVER env var.

CUSTOMIZATION

Uses /etc/gitweb.conf or gitweb_config.perl. Set GIT_INSTAWEB_BROWSER for custom browser.

HISTORY

Introduced in Git 1.5.0 (2007) by Linus Torvalds and others for quick repo inspection. Evolved with web server support expansions; lighttpd default since early versions for speed/simplicity. Actively maintained in Git core.

SEE ALSO

gitweb(1), lighttpd(8), git(1), webrick(1)

Copied to clipboard