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