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