git-svn: allow both diff.color and color.diff
[git/spearce.git] / Documentation / git-clone.txt
blob985043facab96a29e7cf19df213539312e7b5642
1 git-clone(1)
2 ============
4 NAME
5 ----
6 git-clone - Clones a repository
9 SYNOPSIS
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 | --no-separate-remote] <repository>
15           [<directory>]
17 DESCRIPTION
18 -----------
20 Clones a repository into a newly created directory, creates
21 remote-tracking branches for each branch in the cloned repository
22 (visible using `git branch -r`), and creates and checks out a master
23 branch equal to the cloned repository's master branch.
25 After the clone, a plain `git fetch` without arguments will update
26 all the remote-tracking branches, and a `git pull` without
27 arguments will in addition merge the remote master branch into the
28 current branch.
30 This default configuration is achieved by creating references to
31 the remote branch heads under `$GIT_DIR/refs/remotes/origin` and
32 by initializing `remote.origin.url` and `remote.origin.fetch`
33 configuration variables.
35 OPTIONS
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.
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.
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.
62 --quiet::
63 -q::
64         Operate quietly.  This flag is passed to "rsync" and
65         "git-fetch-pack" commands when given.
67 -n::
68         No checkout of HEAD is performed after the clone is complete.
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 the `origin` branch nor the default
80         `remotes/origin` file is created.
82 --origin <name>::
83 -o <name>::
84         Instead of using the branch name 'origin' to keep track
85         of the upstream repository, use <name> instead.  Note
86         that the shorthand name stored in `remotes/origin` is
87         not affected, but the local branch name to pull the
88         remote `master` branch into is.
90 --upload-pack <upload-pack>::
91 -u <upload-pack>::
92         When given, and the repository to clone from is handled
93         by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
94         the command to specify non-default path for the command
95         run on the other end.
97 --template=<template_directory>::
98         Specify the directory from which templates will be used;
99         if unset the templates are taken from the installation
100         defined default, typically `/usr/share/git-core/templates`.
102 --use-separate-remote::
103         Save remotes heads under `$GIT_DIR/remotes/origin/` instead
104         of `$GIT_DIR/refs/heads/`.  Only the local master branch is
105         saved in the latter. This is the default.
107 --no-separate-remote::
108         Save remotes heads in the same namespace as the local
109         heads, `$GIT_DIR/refs/heads/'.  In regular repositories,
110         this is a legacy setup git-clone created by default in
111         older Git versions, and will be removed before the next
112         major release.
114 <repository>::
115         The (possibly remote) repository to clone from.  It can
116         be any URL git-fetch supports.
118 <directory>::
119         The name of a new directory to clone into.  The "humanish"
120         part of the source repository is used if no directory is
121         explicitly given ("repo" for "/path/to/repo.git" and "foo"
122         for "host.xz:foo/.git").  Cloning into an existing directory
123         is not allowed.
125 Examples
126 --------
128 Clone from upstream::
130 ------------
131 $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
132 $ cd my2.6
133 $ make
134 ------------
137 Make a local clone that borrows from the current directory, without checking things out::
139 ------------
140 $ git clone -l -s -n . ../copy
141 $ cd copy
142 $ git show-branch
143 ------------
146 Clone from upstream while borrowing from an existing local directory::
148 ------------
149 $ git clone --reference my2.6 \
150         git://git.kernel.org/pub/scm/.../linux-2.7 \
151         my2.7
152 $ cd my2.7
153 ------------
156 Create a bare repository to publish your changes to the public::
158 ------------
159 $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
160 ------------
163 Create a repository on the kernel.org machine that borrows from Linus::
165 ------------
166 $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
167     /pub/scm/.../me/subsys-2.6.git
168 ------------
171 Author
172 ------
173 Written by Linus Torvalds <torvalds@osdl.org>
176 Documentation
177 --------------
178 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
183 Part of the gitlink:git[7] suite