1GIT-CLONE(1)                      Git Manual                      GIT-CLONE(1)
2
3
4

NAME

6       git-clone - Clone a repository into a new directory
7

SYNOPSIS

9       git clone [--template=<template_directory>]
10                 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
11                 [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
12                 [--depth <depth>] [--recursive|--recurse-submodules] [--] <repository>
13                 [<directory>]
14
15

DESCRIPTION

17       Clones a repository into a newly created directory, creates
18       remote-tracking branches for each branch in the cloned repository
19       (visible using git branch -r), and creates and checks out an initial
20       branch that is forked from the cloned repository’s currently active
21       branch.
22
23       After the clone, a plain git fetch without arguments will update all
24       the remote-tracking branches, and a git pull without arguments will in
25       addition merge the remote master branch into the current master branch,
26       if any.
27
28       This default configuration is achieved by creating references to the
29       remote branch heads under refs/remotes/origin and by initializing
30       remote.origin.url and remote.origin.fetch configuration variables.
31

OPTIONS

33       --local, -l
34           When the repository to clone from is on a local machine, this flag
35           bypasses the normal "git aware" transport mechanism and clones the
36           repository by making a copy of HEAD and everything under objects
37           and refs directories. The files under .git/objects/ directory are
38           hardlinked to save space when possible. This is now the default
39           when the source repository is specified with /path/to/repo syntax,
40           so it essentially is a no-op option. To force copying instead of
41           hardlinking (which may be desirable if you are trying to make a
42           back-up of your repository), but still avoid the usual "git aware"
43           transport mechanism, --no-hardlinks can be used.
44
45       --no-hardlinks
46           Optimize the cloning process from a repository on a local
47           filesystem by copying files under .git/objects directory.
48
49       --shared, -s
50           When the repository to clone is on the local machine, instead of
51           using hard links, automatically setup .git/objects/info/alternates
52           to share the objects with the source repository. The resulting
53           repository starts out without any object of its own.
54
55           NOTE: this is a possibly dangerous operation; do not use it unless
56           you understand what it does. If you clone your repository using
57           this option and then delete branches (or use any other git command
58           that makes any existing commit unreferenced) in the source
59           repository, some objects may become unreferenced (or dangling).
60           These objects may be removed by normal git operations (such as git
61           commit) which automatically call git gc --auto. (See git-gc(1).) If
62           these objects are removed and were referenced by the cloned
63           repository, then the cloned repository will become corrupt.
64
65           Note that running git repack without the -l option in a repository
66           cloned with -s will copy objects from the source repository into a
67           pack in the cloned repository, removing the disk space savings of
68           clone -s. It is safe, however, to run git gc, which uses the -l
69           option by default.
70
71           If you want to break the dependency of a repository cloned with -s
72           on its source repository, you can simply run git repack -a to copy
73           all objects from the source repository into a pack in the cloned
74           repository.
75
76       --reference <repository>
77           If the reference repository is on the local machine, automatically
78           setup .git/objects/info/alternates to obtain objects from the
79           reference repository. Using an already existing repository as an
80           alternate will require fewer objects to be copied from the
81           repository being cloned, reducing network and local storage costs.
82
83           NOTE: see the NOTE for the --shared option.
84
85       --quiet, -q
86           Operate quietly. Progress is not reported to the standard error
87           stream. This flag is also passed to the ‘rsync’ command when given.
88
89       --verbose, -v
90           Run verbosely. Does not affect the reporting of progress status to
91           the standard error stream.
92
93       --progress
94           Progress status is reported on the standard error stream by default
95           when it is attached to a terminal, unless -q is specified. This
96           flag forces progress status even if the standard error stream is
97           not directed to a terminal.
98
99       --no-checkout, -n
100           No checkout of HEAD is performed after the clone is complete.
101
102       --bare
103           Make a bare GIT repository. That is, instead of creating
104           <directory> and placing the administrative files in
105           <directory>/.git, make the <directory> itself the $GIT_DIR. This
106           obviously implies the -n because there is nowhere to check out the
107           working tree. Also the branch heads at the remote are copied
108           directly to corresponding local branch heads, without mapping them
109           to refs/remotes/origin/. When this option is used, neither
110           remote-tracking branches nor the related configuration variables
111           are created.
112
113       --mirror
114           Set up a mirror of the source repository. This implies --bare.
115           Compared to --bare, --mirror not only maps local branches of the
116           source to local branches of the target, it maps all refs (including
117           remote-tracking branches, notes etc.) and sets up a refspec
118           configuration such that all these refs are overwritten by a git
119           remote update in the target repository.
120
121       --origin <name>, -o <name>
122           Instead of using the remote name origin to keep track of the
123           upstream repository, use <name>.
124
125       --branch <name>, -b <name>
126           Instead of pointing the newly created HEAD to the branch pointed to
127           by the cloned repository’s HEAD, point to <name> branch instead. In
128           a non-bare repository, this is the branch that will be checked out.
129
130       --upload-pack <upload-pack>, -u <upload-pack>
131           When given, and the repository to clone from is accessed via ssh,
132           this specifies a non-default path for the command run on the other
133           end.
134
135       --template=<template_directory>
136           Specify the directory from which templates will be used; (See the
137           "TEMPLATE DIRECTORY" section of git-init(1).)
138
139       --depth <depth>
140           Create a shallow clone with a history truncated to the specified
141           number of revisions. A shallow repository has a number of
142           limitations (you cannot clone or fetch from it, nor push from nor
143           into it), but is adequate if you are only interested in the recent
144           history of a large project with a long history, and would want to
145           send in fixes as patches.
146
147       --recursive, --recurse-submodules
148           After the clone is created, initialize all submodules within, using
149           their default settings. This is equivalent to running git submodule
150           update --init --recursive immediately after the clone is finished.
151           This option is ignored if the cloned repository does not have a
152           worktree/checkout (i.e. if any of --no-checkout/-n, --bare, or
153           --mirror is given)
154
155       <repository>
156           The (possibly remote) repository to clone from. See the URLS
157           section below for more information on specifying repositories.
158
159       <directory>
160           The name of a new directory to clone into. The "humanish" part of
161           the source repository is used if no directory is explicitly given
162           (repo for /path/to/repo.git and foo for host.xz:foo/.git). Cloning
163           into an existing directory is only allowed if the directory is
164           empty.
165

GIT URLS

167       In general, URLs contain information about the transport protocol, the
168       address of the remote server, and the path to the repository. Depending
169       on the transport protocol, some of this information may be absent.
170
171       Git natively supports ssh, git, http, https, ftp, ftps, and rsync
172       protocols. The following syntaxes may be used with them:
173
174       ·   ssh://[user@]host.xz[:port]/path/to/repo.git/
175
176       ·   git://host.xz[:port]/path/to/repo.git/
177
178       ·   http[s]://host.xz[:port]/path/to/repo.git/
179
180       ·   ftp[s]://host.xz[:port]/path/to/repo.git/
181
182       ·   rsync://host.xz/path/to/repo.git/
183
184       An alternative scp-like syntax may also be used with the ssh protocol:
185
186       ·   [user@]host.xz:path/to/repo.git/
187
188       The ssh and git protocols additionally support ~username expansion:
189
190       ·   ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
191
192       ·   git://host.xz[:port]/~[user]/path/to/repo.git/
193
194       ·   [user@]host.xz:/~[user]/path/to/repo.git/
195
196       For local repositories, also supported by git natively, the following
197       syntaxes may be used:
198
199       ·   /path/to/repo.git/
200
201       ·    file:///path/to/repo.git/
202
203       These two syntaxes are mostly equivalent, except the former implies
204       --local option.
205
206       When git doesn’t know how to handle a certain transport protocol, it
207       attempts to use the remote-<transport> remote helper, if one exists. To
208       explicitly request a remote helper, the following syntax may be used:
209
210       ·   <transport>::<address>
211
212       where <address> may be a path, a server and path, or an arbitrary
213       URL-like string recognized by the specific remote helper being invoked.
214       See git-remote-helpers(1) for details.
215
216       If there are a large number of similarly-named remote repositories and
217       you want to use a different format for them (such that the URLs you use
218       will be rewritten into URLs that work), you can create a configuration
219       section of the form:
220
221                   [url "<actual url base>"]
222                           insteadOf = <other url base>
223
224
225       For example, with this:
226
227                   [url "git://git.host.xz/"]
228                           insteadOf = host.xz:/path/to/
229                           insteadOf = work:
230
231
232       a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
233       rewritten in any context that takes a URL to be
234       "git://git.host.xz/repo.git".
235
236       If you want to rewrite URLs for push only, you can create a
237       configuration section of the form:
238
239                   [url "<actual url base>"]
240                           pushInsteadOf = <other url base>
241
242
243       For example, with this:
244
245                   [url "ssh://example.org/"]
246                           pushInsteadOf = git://example.org/
247
248
249       a URL like "git://example.org/path/to/repo.git" will be rewritten to
250       "ssh://example.org/path/to/repo.git" for pushes, but pulls will still
251       use the original URL.
252

EXAMPLES

254       ·   Clone from upstream:
255
256               $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
257               $ cd my2.6
258               $ make
259
260
261       ·   Make a local clone that borrows from the current directory, without
262           checking things out:
263
264               $ git clone -l -s -n . ../copy
265               $ cd ../copy
266               $ git show-branch
267
268
269       ·   Clone from upstream while borrowing from an existing local
270           directory:
271
272               $ git clone --reference my2.6 \
273                       git://git.kernel.org/pub/scm/.../linux-2.7 \
274                       my2.7
275               $ cd my2.7
276
277
278       ·   Create a bare repository to publish your changes to the public:
279
280               $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
281
282
283       ·   Create a repository on the kernel.org machine that borrows from
284           Linus:
285
286               $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
287                   /pub/scm/.../me/subsys-2.6.git
288
289

AUTHOR

291       Written by Linus Torvalds <torvalds@osdl.org[1]>
292

DOCUMENTATION

294       Documentation by Junio C Hamano and the git-list
295       <git@vger.kernel.org[2]>.
296

GIT

298       Part of the git(1) suite
299

NOTES

301        1. torvalds@osdl.org
302           mailto:torvalds@osdl.org
303
304        2. git@vger.kernel.org
305           mailto:git@vger.kernel.org
306
307
308
309Git 1.7.4.4                       04/11/2011                      GIT-CLONE(1)
Impressum