LinuxCommandLibrary

git-receive-pack

Receive pushed Git objects from a client

SYNOPSIS

git receive-pack [--stateless-rpc] <git-dir>

PARAMETERS

--stateless-rpc
    Use the stateless RPC protocol for data transfer.

<git-dir>
    The path to the Git repository to update.

DESCRIPTION

The git-receive-pack command is typically invoked by git push on the remote end to receive objects being pushed. It reads data from standard input (which is normally a pipe from the sender end), and updates the repository accordingly. The command verifies that the objects being pushed are valid and authorized before updating the repository. It checks the user's permissions, applies any necessary transformations (like delta compression), and finally stores the new objects and updates the refs.

git-receive-pack is not typically run directly by users. Instead, it's automatically invoked by Git when a push operation is performed to a remote repository. It acts as a server-side component, handling the receiving and processing of data pushed from client repositories. Because this command modifies the git repository it's extremely important to configure correctly to avoid unauthorized commits.

CAVEATS

Improper configuration of git-receive-pack can lead to security vulnerabilities, allowing unauthorized users to modify the repository.

git-receive-pack requires write access to the repository directory, so ensure proper file system permissions are in place.

HOOKS

git-receive-pack triggers several hooks during the push process, notably pre-receive, update, and post-receive. These hooks allow administrators to enforce policies, perform checks, and automate tasks related to repository updates.

SECURITY

Access control is a primary concern when using git-receive-pack. Ensure that the repository directory has appropriate permissions and that only authorized users have write access. Gitolite and other access control tools are often used to manage permissions effectively.

HISTORY

git-receive-pack has been a core part of Git since its early days, providing the crucial functionality for receiving and processing pushed objects. Its development has been closely tied to the evolution of the Git protocol, with updates addressing security concerns, performance improvements, and the addition of features like the stateless RPC protocol.

SEE ALSO

Copied to clipboard