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.
git daemon Syntax:
Section titled “git daemon Syntax:”git daemon [<options>] [<directory>...]Options:
Section titled “Options:”| Option | Description |
|---|---|
| —verbose, -v | Report more detail to stderr or syslog |
| —syslog | Log errors to syslog instead of stderr |
| —export-all | Allow 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-relaxed | Allow ~user notation to be used in addition to the base path |
| —interpolated-path= | Dynamically construct alternate paths |
| —reuseaddr | Reuse 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 |
| —detach | Detach the daemon from the console |
| —inetd | Have the server run as an inetd service |
| —user= | Change daemon’s uid and gid after binding to port |
| —enable= | Enable/disable services (upload-pack, upload-archive, receive-pack) |
| —allow-override, —forbid-override | Allow/forbid overriding site-wide service availability |
| —access-hook= | Execute the given access hook for each served repository |
| —informative-errors | Report more detailed error messages |
| —timeout= | Timeout for client connections |
| —max-connections= | Maximum number of concurrent connections |
| —help | Display help information |
Parameters:
Section titled “Parameters:”| Parameter | Description |
|---|---|
| Directories containing Git repositories to serve |
git daemon Command Samples:
Section titled “git daemon Command Samples:”Serve git repositories in current directory
Section titled “Serve git repositories in current directory”git daemon --verbose --export-allStarts daemon to serve all Git repositories in current directory with verbose output.
Serve specific repositories
Section titled “Serve specific repositories”git daemon --verbose /path/to/repo1 /path/to/repo2Serves only the specified repositories.
Listen on specific port and interface
Section titled “Listen on specific port and interface”git daemon --listen=192.168.1.100 --port=9418 --export-allBinds to specific IP address and port.
Run as background daemon
Section titled “Run as background daemon”git daemon --detach --pid-file=/var/run/git-daemon.pid --export-allRuns as detached daemon process with pid file.
With base path remapping
Section titled “With base path remapping”git daemon --base-path=/var/git --export-allAllows clients to access repositories with shortened URLs.
Enable receive-pack for push support
Section titled “Enable receive-pack for push support”git daemon --enable=receive-pack --user=git /var/gitAllows authenticated users to push changes (not secure for public access).
Allow interpolated paths
Section titled “Allow interpolated paths”git daemon --interpolated-path=/var/git/%IP/%D /var/gitAllows directories based on client IP addresses.
How do I start a Git daemon server?
Section titled “How do I start a Git daemon server?”To start a Git daemon server, use:
git daemon --export-all --verboseHow 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:
git daemon --port=9418 --export-allHow 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:
git daemon --detach --pid-file=/var/run/git-daemon.pid --export-allHow can I restrict daemon to specific repositories?
Section titled “How can I restrict daemon to specific repositories?”To restrict daemon to specific repositories, use:
git daemon /path/to/repo1 /path/to/repo2How do I enable pushing with Git daemon?
Section titled “How do I enable pushing with Git daemon?”To enable pushing with Git daemon, run:
git daemon --enable=receive-pack --user=git-user /var/gitApplications of the git daemon command
Section titled “Applications of the git daemon command”- Providing public read-only access to open source repositories
- Supporting CI/CD systems that clone repositories over git://
- Hosting mirror repositories for faster access
- Enabling development teams to share repositories internally
- Reducing server load by allowing direct cloning from development machines
- Supporting legacy systems that require git:// protocol access