Progress:
TIER 3 · MODULE 45· Expert

git daemon

The simplest possible Git server. No auth, no encryption.

🎯 What & why

git daemon is the reference server for the git:// protocol — a tiny TCP listener that speaks the native pack protocol on port 9418. No auth, no encryption.

🧠 Mental model

Think 'anonymous read-only mirror'. The daemon multiplexes upload-pack (and optionally receive-pack) over a raw TCP socket; transport security, if you want any, is somebody else's problem (VPN, SSH tunnel, firewall).

🛠️ Synopsis

git daemon [--verbose] [--syslog] [--export-all] [--timeout=<n>]
           [--init-timeout=<n>] [--max-connections=<n>] [--strict-paths]
           [--base-path=<path>] [--base-path-relaxed] [--user-path[=<path>]]
           [--interpolated-path=<fmt>] [--reuseaddr] [--detach]
           [--pid-file=<file>] [--user=<user> [--group=<group>]]
           [--enable=<service>] [--disable=<service>]
           [--allow-override=<service>] [--forbid-override=<service>]
           [--access-hook=<path>] [--[no-]informative-errors]
           [--inetd | [--listen=<host>] [--port=<n>]]
           [--log-destination=(stderr|syslog|none)] [<directory>...]

🎚️ Switches & options

FlagWhat it does
--export-allServe every repo under base-path, not just those with git-daemon-export-ok
--base-path=<path>Treat <path> as the root for all incoming repo paths
--listen=<addr>Bind to a specific interface (default: all)
--port=<n>Listen on this TCP port (default: 9418)
--enable=<service>Enable a service (e.g. receive-pack — usually a bad idea)
--disable=<service>Disable a service (upload-pack, upload-archive, receive-pack)
--inetdRun as an inetd-managed service (one connection per invocation)
--detachDetach from the controlling terminal — daemonize
--pid-file=<file>Write the daemon PID here for init scripts
--user=<user>Drop privileges to this user after binding
--group=<group>Drop to this group (requires --user)
--syslogLog to syslog instead of stderr
--log-destination=<dest>Pick stderr, syslog, or none explicitly
--enable=receive-pack⚠️ Allow anonymous push — almost never what you want

💡 Use cases

🧪 Examples

Quick read-only server on 127.0.0.1
git daemon --reuseaddr --base-path=/srv/git --export-all --listen=127.0.0.1 --port=9418
Verbose foreground for debugging
git daemon --verbose --base-path=/srv/git --export-all --listen=127.0.0.1
Detached, drop privileges, syslog
git daemon --detach --user=git --group=git --syslog --pid-file=/run/git-daemon.pid --base-path=/srv/git --export-all
Clone from it
git clone git://127.0.0.1/myrepo.git

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.