← 返回命令列表

Linux command

git-daemon 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Start Git daemon

git daemon --base-path=[/path/to/repos]

Enable upload-pack

git daemon --enable=upload-pack --base-path=[/repos]

Allow push

git daemon --enable=receive-pack --base-path=[/repos]

Run in foreground

git daemon --verbose --base-path=[/repos]

Export all directories

git daemon --export-all --base-path=[/repos]

说明

git daemon provides a simple, lightweight server for Git repositories using the git:// protocol. It enables anonymous read access to repositories by default, with optional write access when explicitly enabled, making it suitable for public repository hosting and internal network sharing. The daemon listens on port 9418 by default and serves repositories from a specified base path. Unlike HTTP-based Git servers, git daemon requires no web server setup, offering minimal overhead for read-only repository access. Security is intentionally limited: repositories must be explicitly exported (via --export-all or git-daemon-export-ok file), and write access should only be enabled in trusted environments. For production systems requiring authentication and encryption, HTTPS or SSH protocols are recommended instead.

参数

--base-path _path_
Base path for repositories.
--export-all
Export all repositories.
--enable _service_
Enable service.
--disable _service_
Disable service.
--port _port_
Listen port (default 9418).
--listen _host_
Listen address.
--verbose
Log details.
--inetd
Run from inetd.

FAQ

What is the git-daemon command used for?

git daemon provides a simple, lightweight server for Git repositories using the git:// protocol. It enables anonymous read access to repositories by default, with optional write access when explicitly enabled, making it suitable for public repository hosting and internal network sharing. The daemon listens on port 9418 by default and serves repositories from a specified base path. Unlike HTTP-based Git servers, git daemon requires no web server setup, offering minimal overhead for read-only repository access. Security is intentionally limited: repositories must be explicitly exported (via --export-all or git-daemon-export-ok file), and write access should only be enabled in trusted environments. For production systems requiring authentication and encryption, HTTPS or SSH protocols are recommended instead.

How do I run a basic git-daemon example?

Run `git daemon --base-path=[/path/to/repos]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --base-path _path_ do in git-daemon?

Base path for repositories.