Documentation / git-receive-pack.txton commit Merge branch 'ar/merge-recursive' (141d21b)
   1git-receive-pack(1)
   2===================
   3
   4NAME
   5----
   6git-receive-pack - Receive what is pushed into it
   7
   8
   9SYNOPSIS
  10--------
  11'git-receive-pack' <directory>
  12
  13DESCRIPTION
  14-----------
  15Invoked by 'git-send-pack' and updates the repository with the
  16information fed from the remote end.
  17
  18This command is usually not invoked directly by the end user.
  19The UI for the protocol is on the 'git-send-pack' side, and the
  20program pair is meant to be used to push updates to remote
  21repository.  For pull operations, see 'git-fetch-pack'.
  22
  23The command allows for creation and fast forwarding of sha1 refs
  24(heads/tags) on the remote end (strictly speaking, it is the
  25local end receive-pack runs, but to the user who is sitting at
  26the send-pack end, it is updating the remote.  Confused?)
  27
  28Before each ref is updated, if $GIT_DIR/hooks/update file exists
  29and executable, it is called with three parameters:
  30
  31       $GIT_DIR/hooks/update refname sha1-old sha1-new
  32
  33The refname parameter is relative to $GIT_DIR; e.g. for the
  34master head this is "refs/heads/master".  Two sha1 are the
  35object names for the refname before and after the update.  Note
  36that the hook is called before the refname is updated, so either
  37sha1-old is 0{40} (meaning there is no such ref yet), or it
  38should match what is recorded in refname.
  39
  40The hook should exit with non-zero status if it wants to
  41disallow updating the named ref.  Otherwise it should exit with
  42zero.
  43
  44Using this hook, it is easy to generate mails on updates to
  45the local repository. This example script sends a mail with
  46the commits pushed to the repository:
  47
  48        #!/bin/sh
  49        # mail out commit update information.
  50        if expr "$2" : '0*$' >/dev/null
  51        then
  52                echo "Created a new ref, with the following commits:"
  53                git-rev-list --pretty "$2"
  54        else
  55                echo "New commits:"
  56                git-rev-list --pretty "$3" "^$2"
  57        fi |
  58        mail -s "Changes to ref $1" commit-list@mydomain
  59        exit 0
  60
  61Another hook $GIT_DIR/hooks/post-update, if exists and
  62executable, is called with the list of refs that have been
  63updated.  This can be used to implement repository wide cleanup
  64task if needed.  The exit code from this hook invocation is
  65ignored; the only thing left for git-receive-pack to do at that
  66point is to exit itself anyway.  This hook can be used, for
  67example, to run "git-update-server-info" if the repository is
  68packed and is served via a dumb transport.
  69
  70        #!/bin/sh
  71        exec git-update-server-info
  72
  73There are other real-world examples of using update and
  74post-update hooks found in the Documentation/howto directory.
  75
  76git-receive-pack honours the receive.denyNonFastforwards flag, which
  77tells it if updates to a ref should be denied if they are not fast-forwards.
  78
  79OPTIONS
  80-------
  81<directory>::
  82        The repository to sync into.
  83
  84
  85SEE ALSO
  86--------
  87gitlink:git-send-pack[1]
  88
  89
  90Author
  91------
  92Written by Linus Torvalds <torvalds@osdl.org>
  93
  94Documentation
  95--------------
  96Documentation by Junio C Hamano.
  97
  98GIT
  99---
 100Part of the gitlink:git[7] suite