Make git-add behave more sensibly in a case-insensitive environment
[git/git.git] / Documentation / git-clone.txt
1 git-clone(1)
2 ============
3
4 NAME
5 ----
6 git-clone - Clone a repository into a new directory
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git-clone' [--template=<template_directory>]
13 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare]
14 [-o <name>] [-u <upload-pack>] [--reference <repository>]
15 [--depth <depth>] [--] <repository> [<directory>]
16
17 DESCRIPTION
18 -----------
19
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 an initial
23 branch equal to the cloned repository's currently active branch.
24
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 master branch, if any.
29
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.
34
35
36 OPTIONS
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. This is now the default when
46 the source repository is specified with `/path/to/repo`
47 syntax, so it essentially is a no-op option. To force
48 copying instead of hardlinking (which may be desirable
49 if you are trying to make a back-up of your repository),
50 but still avoid the usual "git aware" transport
51 mechanism, `--no-hardlinks` can be used.
52
53 --no-hardlinks::
54 Optimize the cloning process from a repository on a
55 local filesystem by copying files under `.git/objects`
56 directory.
57
58 --shared::
59 -s::
60 When the repository to clone is on the local machine,
61 instead of using hard links, automatically setup
62 .git/objects/info/alternates to share the objects
63 with the source repository. The resulting repository
64 starts out without any object of its own.
65 +
66 *NOTE*: this is a possibly dangerous operation; do *not* use
67 it unless you understand what it does. If you clone your
68 repository using this option, then delete branches in the
69 source repository and then run linkgit:git-gc[1] using the
70 '--prune' option in the source repository, it may remove
71 objects which are referenced by the cloned repository.
72
73
74
75 --reference <repository>::
76 If the reference repository is on the local machine
77 automatically setup .git/objects/info/alternates to
78 obtain objects from the reference repository. Using
79 an already existing repository as an alternate will
80 require fewer objects to be copied from the repository
81 being cloned, reducing network and local storage costs.
82
83 --quiet::
84 -q::
85 Operate quietly. This flag is passed to "rsync" and
86 "git-fetch-pack" commands when given.
87
88 --no-checkout::
89 -n::
90 No checkout of HEAD is performed after the clone is complete.
91
92 --bare::
93 Make a 'bare' GIT repository. That is, instead of
94 creating `<directory>` and placing the administrative
95 files in `<directory>/.git`, make the `<directory>`
96 itself the `$GIT_DIR`. This obviously implies the `-n`
97 because there is nowhere to check out the working tree.
98 Also the branch heads at the remote are copied directly
99 to corresponding local branch heads, without mapping
100 them to `refs/remotes/origin/`. When this option is
101 used, neither remote-tracking branches nor the related
102 configuration variables are created.
103
104 --origin <name>::
105 -o <name>::
106 Instead of using the remote name 'origin' to keep track
107 of the upstream repository, use <name> instead.
108
109 --upload-pack <upload-pack>::
110 -u <upload-pack>::
111 When given, and the repository to clone from is handled
112 by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
113 the command to specify non-default path for the command
114 run on the other end.
115
116 --template=<template_directory>::
117 Specify the directory from which templates will be used;
118 if unset the templates are taken from the installation
119 defined default, typically `/usr/share/git-core/templates`.
120
121 --depth <depth>::
122 Create a 'shallow' clone with a history truncated to the
123 specified number of revisions. A shallow repository has a
124 number of limitations (you cannot clone or fetch from
125 it, nor push from nor into it), but is adequate if you
126 are only interested in the recent history of a large project
127 with a long history, and would want to send in fixes
128 as patches.
129
130 <repository>::
131 The (possibly remote) repository to clone from. See the
132 <<URLS,URLS>> section below for more information on specifying
133 repositories.
134
135 <directory>::
136 The name of a new directory to clone into. The "humanish"
137 part of the source repository is used if no directory is
138 explicitly given ("repo" for "/path/to/repo.git" and "foo"
139 for "host.xz:foo/.git"). Cloning into an existing directory
140 is not allowed.
141
142 :git-clone: 1
143 include::urls.txt[]
144
145 Examples
146 --------
147
148 Clone from upstream::
149 +
150 ------------
151 $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
152 $ cd my2.6
153 $ make
154 ------------
155
156
157 Make a local clone that borrows from the current directory, without checking things out::
158 +
159 ------------
160 $ git clone -l -s -n . ../copy
161 $ cd ../copy
162 $ git show-branch
163 ------------
164
165
166 Clone from upstream while borrowing from an existing local directory::
167 +
168 ------------
169 $ git clone --reference my2.6 \
170 git://git.kernel.org/pub/scm/.../linux-2.7 \
171 my2.7
172 $ cd my2.7
173 ------------
174
175
176 Create a bare repository to publish your changes to the public::
177 +
178 ------------
179 $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
180 ------------
181
182
183 Create a repository on the kernel.org machine that borrows from Linus::
184 +
185 ------------
186 $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
187 /pub/scm/.../me/subsys-2.6.git
188 ------------
189
190
191 Author
192 ------
193 Written by Linus Torvalds <torvalds@osdl.org>
194
195
196 Documentation
197 --------------
198 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
199
200
201 GIT
202 ---
203 Part of the linkgit:git[7] suite