Documentation / git-clone.txton commit git-branch -D: make it work even when on a yet-to-be-born branch (67affd5)
   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          [--use-separate-remote | --use-immingled-remote] <repository>
  15          [<directory>]
  16
  17DESCRIPTION
  18-----------
  19Clones a repository into a newly created directory.  All remote
  20branch heads are copied under `$GIT_DIR/refs/heads/`, except
  21that the remote `master` is also copied to `origin` branch.
  22
  23In addition, `$GIT_DIR/remotes/origin` file is set up to have
  24this line:
  25
  26        Pull: master:origin
  27
  28This is to help the typical workflow of working off of the
  29remote `master` branch.  Every time `git pull` without argument
  30is run, the progress on the remote `master` branch is tracked by
  31copying it into the local `origin` branch, and merged into the
  32branch you are currently working on.  Remote branches other than
  33`master` are also added there to be tracked.
  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.
  46
  47--shared::
  48-s::
  49        When the repository to clone is on the local machine,
  50        instead of using hard links, automatically setup
  51        .git/objects/info/alternates to share the objects
  52        with the source repository.  The resulting repository
  53        starts out without any object of its own.
  54
  55--reference <repository>::
  56        If the reference repository is on the local machine
  57        automatically setup .git/objects/info/alternates to
  58        obtain objects from the reference repository.  Using
  59        an already existing repository as an alternate will
  60        require less objects to be copied from the repository
  61        being cloned, reducing network and local storage costs.
  62
  63--quiet::
  64-q::
  65        Operate quietly.  This flag is passed to "rsync" and
  66        "git-fetch-pack" commands when given.
  67
  68-n::
  69        No checkout of HEAD is performed after the clone is complete.
  70
  71--bare::
  72        Make a 'bare' GIT repository.  That is, instead of
  73        creating `<directory>` and placing the administrative
  74        files in `<directory>/.git`, make the `<directory>`
  75        itself the `$GIT_DIR`. This obviously implies the `-n`
  76        because there is nowhere to check out the working tree.
  77        Also the branch heads at the remote are copied directly
  78        to corresponding local branch heads, without mapping
  79        them to `refs/remotes/origin/`.  When this option is
  80        used, neither the `origin` branch nor the default
  81        `remotes/origin` file is created.
  82
  83--origin <name>::
  84-o <name>::
  85        Instead of using the branch name 'origin' to keep track
  86        of the upstream repository, use <name> instead.  Note
  87        that the shorthand name stored in `remotes/origin` is
  88        not affected, but the local branch name to pull the
  89        remote `master` branch into is.
  90
  91--upload-pack <upload-pack>::
  92-u <upload-pack>::
  93        When given, and the repository to clone from is handled
  94        by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
  95        the command to specify non-default path for the command
  96        run on the other end.
  97
  98--template=<template_directory>::
  99        Specify the directory from which templates will be used;
 100        if unset the templates are taken from the installation
 101        defined default, typically `/usr/share/git-core/templates`.
 102
 103--use-separate-remote::
 104        Save remotes heads under `$GIT_DIR/remotes/origin/` instead
 105        of `$GIT_DIR/refs/heads/`.  Only the local master branch is
 106        saved in the latter. This is the default.
 107
 108--use-immingled-remote::
 109        Save remotes heads in the same namespace as the local
 110        heads, `$GIT_DIR/refs/heads/'.  In regular repositories,
 111        this is a legacy setup git-clone created by default in
 112        older Git versions, and will be removed before the next
 113        major release.
 114
 115<repository>::
 116        The (possibly remote) repository to clone from.  It can
 117        be any URL git-fetch supports.
 118
 119<directory>::
 120        The name of a new directory to clone into.  The "humanish"
 121        part of the source repository is used if no directory is
 122        explicitly given ("repo" for "/path/to/repo.git" and "foo"
 123        for "host.xz:foo/.git").  Cloning into an existing directory
 124        is not allowed.
 125
 126Examples
 127--------
 128
 129Clone from upstream::
 130+
 131------------
 132$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
 133$ cd my2.6
 134$ make
 135------------
 136
 137
 138Make a local clone that borrows from the current directory, without checking things out::
 139+
 140------------
 141$ git clone -l -s -n . ../copy
 142$ cd copy
 143$ git show-branch
 144------------
 145
 146
 147Clone from upstream while borrowing from an existing local directory::
 148+
 149------------
 150$ git clone --reference my2.6 \
 151        git://git.kernel.org/pub/scm/.../linux-2.7 \
 152        my2.7
 153$ cd my2.7
 154------------
 155
 156
 157Create a bare repository to publish your changes to the public::
 158+
 159------------
 160$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
 161------------
 162
 163
 164Create a repository on the kernel.org machine that borrows from Linus::
 165+
 166------------
 167$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
 168    /pub/scm/.../me/subsys-2.6.git
 169------------
 170
 171
 172Author
 173------
 174Written by Linus Torvalds <torvalds@osdl.org>
 175
 176
 177Documentation
 178--------------
 179Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
 180
 181
 182GIT
 183---
 184Part of the gitlink:git[7] suite
 185