Documentation / git-clone.txton commit git-fetch: remove .keep file at the end. (ac9c110)
   1git-clone(1)
   2============
   3
   4NAME
   5----
   6git-clone - Clones a repository
   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          <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 a master
  22branch equal to the cloned repository's master 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 branch.
  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
  34OPTIONS
  35-------
  36--local::
  37-l::
  38        When the repository to clone from is on a local machine,
  39        this flag bypasses normal "git aware" transport
  40        mechanism and clones the repository by making a copy of
  41        HEAD and everything under objects and refs directories.
  42        The files under .git/objects/ directory are hardlinked
  43        to save space when possible.
  44
  45--shared::
  46-s::
  47        When the repository to clone is on the local machine,
  48        instead of using hard links, automatically setup
  49        .git/objects/info/alternates to share the objects
  50        with the source repository.  The resulting repository
  51        starts out without any object of its own.
  52
  53--reference <repository>::
  54        If the reference repository is on the local machine
  55        automatically setup .git/objects/info/alternates to
  56        obtain objects from the reference repository.  Using
  57        an already existing repository as an alternate will
  58        require less objects to be copied from the repository
  59        being cloned, reducing network and local storage costs.
  60
  61--quiet::
  62-q::
  63        Operate quietly.  This flag is passed to "rsync" and
  64        "git-fetch-pack" commands when given.
  65
  66-n::
  67        No checkout of HEAD is performed after the clone is complete.
  68
  69--bare::
  70        Make a 'bare' GIT repository.  That is, instead of
  71        creating `<directory>` and placing the administrative
  72        files in `<directory>/.git`, make the `<directory>`
  73        itself the `$GIT_DIR`. This obviously implies the `-n`
  74        because there is nowhere to check out the working tree.
  75        Also the branch heads at the remote are copied directly
  76        to corresponding local branch heads, without mapping
  77        them to `refs/remotes/origin/`.  When this option is
  78        used, neither remote-tracking branches nor the related
  79        configuration variables are created.
  80
  81--origin <name>::
  82-o <name>::
  83        Instead of using the remote name 'origin' to keep track
  84        of the upstream repository, use <name> instead.
  85
  86--upload-pack <upload-pack>::
  87-u <upload-pack>::
  88        When given, and the repository to clone from is handled
  89        by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
  90        the command to specify non-default path for the command
  91        run on the other end.
  92
  93--template=<template_directory>::
  94        Specify the directory from which templates will be used;
  95        if unset the templates are taken from the installation
  96        defined default, typically `/usr/share/git-core/templates`.
  97
  98<repository>::
  99        The (possibly remote) repository to clone from.  It can
 100        be any URL git-fetch supports.
 101
 102<directory>::
 103        The name of a new directory to clone into.  The "humanish"
 104        part of the source repository is used if no directory is
 105        explicitly given ("repo" for "/path/to/repo.git" and "foo"
 106        for "host.xz:foo/.git").  Cloning into an existing directory
 107        is not allowed.
 108
 109Examples
 110--------
 111
 112Clone from upstream::
 113+
 114------------
 115$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
 116$ cd my2.6
 117$ make
 118------------
 119
 120
 121Make a local clone that borrows from the current directory, without checking things out::
 122+
 123------------
 124$ git clone -l -s -n . ../copy
 125$ cd copy
 126$ git show-branch
 127------------
 128
 129
 130Clone from upstream while borrowing from an existing local directory::
 131+
 132------------
 133$ git clone --reference my2.6 \
 134        git://git.kernel.org/pub/scm/.../linux-2.7 \
 135        my2.7
 136$ cd my2.7
 137------------
 138
 139
 140Create a bare repository to publish your changes to the public::
 141+
 142------------
 143$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
 144------------
 145
 146
 147Create a repository on the kernel.org machine that borrows from Linus::
 148+
 149------------
 150$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
 151    /pub/scm/.../me/subsys-2.6.git
 152------------
 153
 154
 155Author
 156------
 157Written by Linus Torvalds <torvalds@osdl.org>
 158
 159
 160Documentation
 161--------------
 162Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 163
 164
 165GIT
 166---
 167Part of the gitlink:git[7] suite
 168