Skip to main content
The HookService provides methods for executing various Git hooks during repository operations.

PreReceiveHook

Executes the pre-receive hook before references are updated.

Request (Stream)

repository
Repository
required
The repository where the hook is executed
environment_variables
string[]
Environment variables to pass to the hook
stdin
bytes
Data to pass to the hook via stdin
git_push_options
string[]
Git push options to pass to the hook

Response (Stream)

stdout
bytes
Output from the hook’s stdout
stderr
bytes
Output from the hook’s stderr
exit_status
ExitStatus
The exit status of the hook

PostReceiveHook

Executes the post-receive hook after references are updated.

Request (Stream)

repository
Repository
required
The repository where the hook is executed
environment_variables
string[]
Environment variables to pass to the hook
stdin
bytes
Data to pass to the hook via stdin
git_push_options
string[]
Git push options to pass to the hook

Response (Stream)

stdout
bytes
Output from the hook’s stdout
stderr
bytes
Output from the hook’s stderr
exit_status
ExitStatus
The exit status of the hook

UpdateHook

Executes the update hook when a single reference is being updated.

Request

repository
Repository
required
The repository where the hook is executed
environment_variables
string[]
Environment variables to pass to the hook
ref
bytes
required
The reference being updated
old_value
string
required
The old value of the reference
new_value
string
required
The new value of the reference

Response (Stream)

stdout
bytes
Output from the hook’s stdout
stderr
bytes
Output from the hook’s stderr
exit_status
ExitStatus
The exit status of the hook

ReferenceTransactionHook

Executes the reference-transaction hook during different phases of a reference transaction.

Request (Stream)

repository
Repository
required
The repository where the hook is executed
environment_variables
string[]
Environment variables to pass to the hook
stdin
bytes
Data to pass to the hook via stdin
state
State
required
The state of the reference transaction. Values: PREPARED, COMMITTED, ABORTED

Response (Stream)

stdout
bytes
Output from the hook’s stdout
stderr
bytes
Output from the hook’s stderr
exit_status
ExitStatus
The exit status of the hook

PackObjectsHook

Deprecated. Use PackObjectsHookWithSidechannel instead. This method will be removed in version 15.0.
Executes the pack-objects hook.

Request (Stream)

repository
Repository
required
The repository where the hook is executed
args
string[]
Arguments passed to the pack-objects hook, without the leading “git”
stdin
bytes
Data for consumption by git-pack-objects

Response (Stream)

stdout
bytes
Packfile data
stderr
bytes
Progress messages (such as “Enumerating objects …”)

PackObjectsHookWithSidechannel

Optimized version of PackObjectsHook that uses a Unix socket side channel for improved performance.

Request

repository
Repository
required
The repository where the hook is executed
args
string[]
Arguments passed to the pack-objects hook, without the leading “git”

Response

Empty response on success.

Build docs developers (and LLMs) love