Documentation / git-clone.txton commit post-checkout hook, tests, and docs (1abbe47)
   1git-clone(1)
   2============
   3
   4NAME
   5----
   6git-clone - Clone a repository into a new directory
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git-clone' [--template=<template_directory>]
  13          [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare]
  14          [-o <name>] [-u <upload-pack>] [--reference <repository>]
  15          [--depth <depth>] <repository> [<directory>]
  16
  17DESCRIPTION
  18-----------
  19
  20Clones a repository into a newly created directory, creates
  21remote-tracking branches for each branch in the cloned repository
  22(visible using `git branch -r`), and creates and checks out an initial
  23branch equal to the cloned repository's currently active branch.
  24
  25After the clone, a plain `git fetch` without arguments will update
  26all the remote-tracking branches, and a `git pull` without
  27arguments will in addition merge the remote master branch into the
  28current master branch, if any.
  29
  30This default configuration is achieved by creating references to
  31the remote branch heads under `$GIT_DIR/refs/remotes/origin` and
  32by initializing `remote.origin.url` and `remote.origin.fetch`
  33configuration variables.
  34
  35
  36OPTIONS
  37-------
  38--local::
  39-l::
  40        When the repository to clone from is on a local machine,
  41        this flag bypasses normal "git aware" transport
  42        mechanism and clones the repository by making a copy of
  43        HEAD and everything under objects and refs directories.
  44        The files under `.git/objects/` directory are hardlinked
  45        to save space when possible.  This is now the default when
  46        the source repository is specified with `/path/to/repo`
  47        syntax, so it essentially is a no-op option.  To force
  48        copying instead of hardlinking (which may be desirable
  49        if you are trying to make a back-up of your repository),
  50        but still avoid the usual "git aware" transport
  51        mechanism, `--no-hardlinks` can be used.
  52
  53--no-hardlinks::
  54        Optimize the cloning process from a repository on a
  55        local filesystem by copying files under `.git/objects`
  56        directory.
  57
  58--shared::
  59-s::
  60        When the repository to clone is on the local machine,
  61        instead of using hard links, automatically setup
  62        .git/objects/info/alternates to share the objects
  63        with the source repository.  The resulting repository
  64        starts out without any object of its own.
  65
  66--reference <repository>::
  67        If the reference repository is on the local machine
  68        automatically setup .git/objects/info/alternates to
  69        obtain objects from the reference repository.  Using
  70        an already existing repository as an alternate will
  71        require fewer objects to be copied from the repository
  72        being cloned, reducing network and local storage costs.
  73
  74--quiet::
  75-q::
  76        Operate quietly.  This flag is passed to "rsync" and
  77        "git-fetch-pack" commands when given.
  78
  79--no-checkout::
  80-n::
  81        No checkout of HEAD is performed after the clone is complete.
  82
  83--bare::
  84        Make a 'bare' GIT repository.  That is, instead of
  85        creating `<directory>` and placing the administrative
  86        files in `<directory>/.git`, make the `<directory>`
  87        itself the `$GIT_DIR`. This obviously implies the `-n`
  88        because there is nowhere to check out the working tree.
  89        Also the branch heads at the remote are copied directly
  90        to corresponding local branch heads, without mapping
  91        them to `refs/remotes/origin/`.  When this option is
  92        used, neither remote-tracking branches nor the related
  93        configuration variables are created.
  94
  95--origin <name>::
  96-o <name>::
  97        Instead of using the remote name 'origin' to keep track
  98        of the upstream repository, use <name> instead.
  99
 100--upload-pack <upload-pack>::
 101-u <upload-pack>::
 102        When given, and the repository to clone from is handled
 103        by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
 104        the command to specify non-default path for the command
 105        run on the other end.
 106
 107--template=<template_directory>::
 108        Specify the directory from which templates will be used;
 109        if unset the templates are taken from the installation
 110        defined default, typically `/usr/share/git-core/templates`.
 111
 112--depth <depth>::
 113        Create a 'shallow' clone with a history truncated to the
 114        specified number of revs.  A shallow repository has
 115        number of limitations (you cannot clone or fetch from
 116        it, nor push from nor into it), but is adequate if you
 117        want to only look at near the tip of a large project
 118        with a long history, and would want to send in a fixes
 119        as patches.
 120
 121<repository>::
 122        The (possibly remote) repository to clone from.  See the
 123        <<URLS,URLS>> section below for more information on specifying
 124        repositories.
 125
 126<directory>::
 127        The name of a new directory to clone into.  The "humanish"
 128        part of the source repository is used if no directory is
 129        explicitly given ("repo" for "/path/to/repo.git" and "foo"
 130        for "host.xz:foo/.git").  Cloning into an existing directory
 131        is not allowed.
 132
 133include::urls.txt[]
 134
 135Examples
 136--------
 137
 138Clone from upstream::
 139+
 140------------
 141$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
 142$ cd my2.6
 143$ make
 144------------
 145
 146
 147Make a local clone that borrows from the current directory, without checking things out::
 148+
 149------------
 150$ git clone -l -s -n . ../copy
 151$ cd ../copy
 152$ git show-branch
 153------------
 154
 155
 156Clone from upstream while borrowing from an existing local directory::
 157+
 158------------
 159$ git clone --reference my2.6 \
 160        git://git.kernel.org/pub/scm/.../linux-2.7 \
 161        my2.7
 162$ cd my2.7
 163------------
 164
 165
 166Create a bare repository to publish your changes to the public::
 167+
 168------------
 169$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
 170------------
 171
 172
 173Create a repository on the kernel.org machine that borrows from Linus::
 174+
 175------------
 176$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
 177    /pub/scm/.../me/subsys-2.6.git
 178------------
 179
 180
 181Author
 182------
 183Written by Linus Torvalds <torvalds@osdl.org>
 184
 185
 186Documentation
 187--------------
 188Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 189
 190
 191GIT
 192---
 193Part of the gitlink:git[7] suite