Skip to content

daemon Git Command Guide

The git daemon command provides a simple TCP-based server for Git repositories, allowing unauthenticated read access via the git:// protocol. It’s suitable for public or read-only repository hosting.

Terminal window
git daemon [<options>] [<directory>...]
OptionDescription
—verbose, -vReport more detail to stderr or syslog
—syslogLog errors to syslog instead of stderr
—export-allAllow pulling from all directories if no specific directories are given
—base-path Remap all the path requests to be relative to the given path
—base-path-relaxedAllow ~user notation to be used in addition to the base path
—interpolated-path=Dynamically construct alternate paths
—reuseaddrReuse server sockets after program termination
—pid-file=Save the process id to the given file
—listen=Listen on a specific IP address or hostname
—port=Listen on a specific port
—detachDetach the daemon from the console
—inetdHave the server run as an inetd service
—user=, —group=Change daemon’s uid and gid after binding to port
—enable=, —disable=Enable/disable services (upload-pack, upload-archive, receive-pack)
—allow-override, —forbid-overrideAllow/forbid overriding site-wide service availability
—access-hook=Execute the given access hook for each served repository
—informative-errorsReport more detailed error messages
—timeout=Timeout for client connections
—max-connections=Maximum number of concurrent connections
—helpDisplay help information
ParameterDescription
Directories containing Git repositories to serve

Serve git repositories in current directory

Section titled “Serve git repositories in current directory”
Terminal window
git daemon --verbose --export-all

Starts daemon to serve all Git repositories in current directory with verbose output.

Terminal window
git daemon --verbose /path/to/repo1 /path/to/repo2

Serves only the specified repositories.

Terminal window
git daemon --listen=192.168.1.100 --port=9418 --export-all

Binds to specific IP address and port.

Terminal window
git daemon --detach --pid-file=/var/run/git-daemon.pid --export-all

Runs as detached daemon process with pid file.

Terminal window
git daemon --base-path=/var/git --export-all

Allows clients to access repositories with shortened URLs.

Terminal window
git daemon --enable=receive-pack --user=git /var/git

Allows authenticated users to push changes (not secure for public access).

Terminal window
git daemon --interpolated-path=/var/git/%IP/%D /var/git

Allows directories based on client IP addresses.

To start a Git daemon server, use:

Terminal window
git daemon --export-all --verbose

How can I serve Git repositories over a specific port?

Section titled “How can I serve Git repositories over a specific port?”

To serve Git repositories over a specific port, run:

Terminal window
git daemon --port=9418 --export-all

How do I run Git daemon as a background service?

Section titled “How do I run Git daemon as a background service?”

To run Git daemon as a background service, execute:

Terminal window
git daemon --detach --pid-file=/var/run/git-daemon.pid --export-all

How can I restrict daemon to specific repositories?

Section titled “How can I restrict daemon to specific repositories?”

To restrict daemon to specific repositories, use:

Terminal window
git daemon /path/to/repo1 /path/to/repo2

To enable pushing with Git daemon, run:

Terminal window
git daemon --enable=receive-pack --user=git-user /var/git
  1. Providing public read-only access to open source repositories
  2. Supporting CI/CD systems that clone repositories over git://
  3. Hosting mirror repositories for faster access
  4. Enabling development teams to share repositories internally
  5. Reducing server load by allowing direct cloning from development machines
  6. Supporting legacy systems that require git:// protocol access