NAME
git-receive-pack - Receive what is pushed into the repositorySYNOPSIS
git receive-pack <git-dir>
DESCRIPTION
Invoked by git send-pack and updates the repository with the information fed from the remote end.OPTIONS
<git-dir>The repository to sync into.
--http-backend-info-refs
Used by git-http-backend(1) to serve up
$GIT_URL/info/refs?service=git-receive-pack requests. See
--http-backend-info-refs in git-upload-pack(1).
PRE-RECEIVE HOOK
Before any ref is updated, if $GIT_DIR/hooks/pre-receive file exists and is executable, it will be invoked once with no parameters. The standard input of the hook will be one line per ref to be updated:sha1-old SP sha1-new SP refname LF
The name and the e-mail address of the owner
of the key that signed the push certificate.
GIT_PUSH_CERT_KEY
The GPG key ID of the key that signed the push
certificate.
GIT_PUSH_CERT_STATUS
The status of GPG verification of the push
certificate, using the same mnemonic as used in %G? format of git
log family of commands (see git-log(1)).
GIT_PUSH_CERT_NONCE
The nonce string the process asked the signer
to include in the push certificate. If this does not match the value recorded
on the "nonce" header in the push certificate, it may indicate that
the certificate is a valid one that is being replayed from a separate
"git push" session.
GIT_PUSH_CERT_NONCE_STATUS
UNSOLICITED
GIT_PUSH_CERT_NONCE_SLOP
"git push --signed" sent a nonce
when we did not ask it to send one.
MISSING
"git push --signed" did not send any
nonce header.
BAD
"git push --signed" sent a bogus
nonce.
OK
"git push --signed" sent the nonce
we asked it to send.
SLOP
"git push --signed" sent a nonce
different from what we asked it to send now, but in a previous session. See
GIT_PUSH_CERT_NONCE_SLOP environment variable.
"git push --signed" sent a nonce
different from what we asked it to send now, but in a different session whose
starting time is different by this many seconds from the current session. Only
meaningful when GIT_PUSH_CERT_NONCE_STATUS says SLOP. Also read
about receive.certNonceSlop variable in git-config(1).
UPDATE HOOK
Before each ref is updated, if $GIT_DIR/hooks/update file exists and is executable, it is invoked once per ref, with three parameters:$GIT_DIR/hooks/update refname sha1-old sha1-new
POST-RECEIVE HOOK
After all refs were updated (or attempted to be updated), if any ref update was successful, and if $GIT_DIR/hooks/post-receive file exists and is executable, it will be invoked once with no parameters. The standard input of the hook will be one line for each successfully updated ref:sha1-old SP sha1-new SP refname LF
#!/bin/sh # mail out commit update information. while read oval nval ref do if expr "$oval" : '0*$' >/dev/null then echo "Created a new ref, with the following commits:" git rev-list --pretty "$nval" else echo "New commits:" git rev-list --pretty "$nval" "^$oval" fi | mail -s "Changes to ref $ref" commit-list@mydomain done # log signed push certificate, if any if test -n "${GIT_PUSH_CERT-}" && test ${GIT_PUSH_CERT_STATUS} = G then ( echo expected nonce is ${GIT_PUSH_NONCE} git cat-file blob ${GIT_PUSH_CERT} ) | mail -s "push certificate from $GIT_PUSH_CERT_SIGNER" push-log@mydomain fi exit 0
POST-UPDATE HOOK
After all other processing, if at least one ref was updated, and if $GIT_DIR/hooks/post-update file exists and is executable, then post-update will be called with the list of refs that have been updated. This can be used to implement any repository wide cleanup tasks.#!/bin/sh exec git update-server-info
QUARANTINE ENVIRONMENT
When receive-pack takes in objects, they are placed into a temporary "quarantine" directory within the $GIT_DIR/objects directory and migrated into the main object store only after the pre-receive hook has completed. If the push fails before then, the temporary directory is removed entirely. 1.Pushes which fail due to problems with the
incoming pack, missing objects, or due to the pre-receive hook will not
leave any on-disk data. This is usually helpful to prevent repeated failed
pushes from filling up your disk, but can make debugging more
challenging.
2.Any objects created by the
pre-receive hook will be created in the quarantine directory (and
migrated only if it succeeds).
3.The pre-receive hook MUST NOT update
any refs to point to quarantined objects. Other programs accessing the
repository will not be able to see the objects (and if the pre-receive hook
fails, those refs would become corrupted). For safety, any ref updates from
within pre-receive are automatically rejected.
SEE ALSO
git-send-pack(1), gitnamespaces(7)GIT
Part of the git(1) suite02/28/2023 | Git 2.39.2 |