← 返回命令列表

Linux command

git-update-server-info 命令

文本

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

常用示例

Regenerate

git update-server-info

Force a full rebuild

git update-server-info --force

Run from inside a bare repository

git -C [path/to/repo.git] update-server-info

Automatically refresh

cp [path/to/repo.git]/hooks/post-update.sample [path/to/repo.git]/hooks/post-update

说明

git update-server-info writes the auxiliary index files that allow a "dumb" HTTP, FTP, or rsync server to serve a Git repository without running any Git-aware service. A dumb server simply delivers raw files from disk, so it cannot enumerate refs or generate packs on the fly. The auxiliary files give clients enough metadata to discover what references and packs exist. The command regenerates objects/info/packs, which lists every pack file in the object store, and info/refs, which lists every reference with its target object name. Clients fetching over a dumb transport read these files to plan what objects they need to download. This step is unnecessary for repositories served by git-daemon, git-http-backend, or any other "smart" transport, because those services compute the same information on demand. It is only required for plain file servers such as Apache without the smart Git CGI, S3 buckets exposed over HTTP, or static hosting providers. The stock post-update hook shipped with Git invokes this command, so enabling it on the server is usually the only setup needed. After every push, the hook refreshes the info files so subsequent dumb clients see the latest state.

参数

-f, --force
Update the info files from scratch, ignoring any cached or partial state. Useful after manual repacking, when packs have been added or removed outside of Git's normal flow, or when the info files appear out of sync with the repository contents.

FAQ

What is the git-update-server-info command used for?

git update-server-info writes the auxiliary index files that allow a "dumb" HTTP, FTP, or rsync server to serve a Git repository without running any Git-aware service. A dumb server simply delivers raw files from disk, so it cannot enumerate refs or generate packs on the fly. The auxiliary files give clients enough metadata to discover what references and packs exist. The command regenerates objects/info/packs, which lists every pack file in the object store, and info/refs, which lists every reference with its target object name. Clients fetching over a dumb transport read these files to plan what objects they need to download. This step is unnecessary for repositories served by git-daemon, git-http-backend, or any other "smart" transport, because those services compute the same information on demand. It is only required for plain file servers such as Apache without the smart Git CGI, S3 buckets exposed over HTTP, or static hosting providers. The stock post-update hook shipped with Git invokes this command, so enabling it on the server is usually the only setup needed. After every push, the hook refreshes the info files so subsequent dumb clients see the latest state.

How do I run a basic git-update-server-info example?

Run `git update-server-info` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -f, --force do in git-update-server-info?

Update the info files from scratch, ignoring any cached or partial state. Useful after manual repacking, when packs have been added or removed outside of Git's normal flow, or when the info files appear out of sync with the repository contents.