Documentation / git-clone.txton commit Documentation: finishing touches to the new tutorial. (dcc6e28)
   1git-clone(1)
   2============
   3
   4NAME
   5----
   6git-clone - Clones a repository.
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git-clone' [-l [-s]] [-q] [-n] [--naked] [-o <name>] [-u <upload-pack>]
  13          <repository> [<directory>]
  14
  15DESCRIPTION
  16-----------
  17Clones a repository into a newly created directory.  All remote
  18branch heads are copied under `$GIT_DIR/refs/heads/`, except
  19that the remote `master` is also copied to `origin` branch.
  20
  21In addition, `$GIT_DIR/remotes/origin` file is set up to have
  22this line:
  23
  24        Pull: master:origin
  25
  26This is to help the typical workflow of working off of the
  27remote `master` branch.  Every time `git pull` without argument
  28is run, the progress on the remote `master` branch is tracked by
  29copying it into the local `origin` branch, and merged into the
  30branch you are currently working on.  Remote branches other than
  31`master` are also added there to be tracked.
  32
  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/alternatives to share the objects
  50        with the source repository.  The resulting repository
  51        starts out without any object of its own.
  52
  53--quiet::
  54-q::
  55        Operate quietly.  This flag is passed to "rsync" and
  56        "git-clone-pack" commands when given.
  57
  58-n::
  59        No checkout of HEAD is performed after the clone is complete.
  60
  61--naked::
  62        Make a 'naked' GIT repository.  That is, instead of
  63        creating `<directory>` and placing the administrative
  64        files in `<directory>/.git`, make the `<directory>`
  65        itself the `$GIT_DIR`. This implies `-n` option.
  66
  67-o <name>::
  68        Instead of using the branch name 'origin' to keep track
  69        of the upstream repository, use <name> instead.  Note
  70        that the shorthand name stored in `remotes/origin` is
  71        not affected, but the local branch name to pull the
  72        remote `master` branch into is.
  73
  74--upload-pack <upload-pack>::
  75-u <upload-pack>::
  76        When given, and the repository to clone from is handled
  77        by 'git-clone-pack', '--exec=<upload-pack>' is passed to
  78        the command to specify non-default path for the command
  79        run on the other end.
  80
  81<repository>::
  82        The (possibly remote) repository to clone from.  It can
  83        be any URL git-fetch supports.
  84
  85<directory>::
  86        The name of a new directory to clone into.  The "humanish"
  87        part of the source repository is used if no directory is
  88        explicitly given ("repo" for "/path/to/repo.git" and "foo"
  89        for "host.xz:foo/.git").  Cloning into an existing directory
  90        is not allowed.
  91
  92Examples
  93~~~~~~~~
  94
  95Clone from upstream::
  96+
  97------------
  98$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
  99$ cd my2.6
 100$ make
 101------------
 102
 103
 104Make a local clone that borrows from the current directory, without checking things out::
 105+
 106------------
 107$ git clone -l -s -n . ../copy
 108$ cd copy
 109$ git show-branch
 110------------
 111
 112
 113Create a naked repository to publish your changes to the public::
 114+
 115------------
 116$ git clone --naked -l /home/proj/.git /pub/scm/proj.git
 117------------
 118
 119
 120Create a repository on the kernel.org machine that borrows from Linus::
 121+
 122------------
 123$ git clone --naked -l -s /pub/scm/.../torvalds/linux-2.6.git \
 124    /pub/scm/.../me/subsys-2.6.git
 125------------
 126
 127
 128Author
 129------
 130Written by Linus Torvalds <torvalds@osdl.org>
 131
 132
 133Documentation
 134--------------
 135Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 136
 137
 138GIT
 139---
 140Part of the gitlink:git[7] suite
 141