← All languages
Git command of the day
Random

daemon

Run a simple TCP server for the git:// protocol.

Description

git daemon is a lightweight server that exposes Git repositories over the unauthenticated git:// protocol on TCP port 9418. It is most useful inside trusted networks for fast read-only mirroring or for ad-hoc sharing during development.

By default git daemon serves only repositories that contain a git-daemon-export-ok marker file, which protects against accidentally publishing private working copies. With --export-all this safety check is disabled. The --base-path flag lets clients address repositories with short URLs relative to a chosen directory.

Write access via git push must be enabled explicitly with --enable=receive-pack and is rarely a good idea over an unauthenticated channel. For real-world deployments, SSH or HTTPS-based hosting is preferred; git daemon is mainly a teaching and ad-hoc tool.

Arguments

NameDescriptionOptional
--base-path=path Treat the given directory as the root for client URLs. Yes
--export-all Serve repositories regardless of whether they contain git-daemon-export-ok. Yes
--enable=service Enable an optional service such as receive-pack (push) or upload-archive. Yes
--port=n Listen on the given TCP port instead of the default 9418. Yes

Example

git daemon --base-path=/srv/git --export-all --reuseaddr --verbose

# Allow pushes (use with caution)
git daemon --base-path=/srv/git --enable=receive-pack

Reference