1GIT-CLONE(1) Git Manual GIT-CLONE(1)
2
3
4
6 git-clone - Clone a repository into a new directory
7
9 git-clone [--template=<template_directory>]
10 [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare]
11 [-o <name>] [-u <upload-pack>] [--reference <repository>]
12 [--depth <depth>] <repository> [<directory>]
13
15 Clones a repository into a newly created directory, creates
16 remote-tracking branches for each branch in the cloned repository
17 (visible using git branch -r), and creates and checks out an initial
18 branch equal to the cloned repository´s currently active branch.
19
20 After the clone, a plain git fetch without arguments will update all
21 the remote-tracking branches, and a git pull without arguments will in
22 addition merge the remote master branch into the current master branch,
23 if any.
24
25 This default configuration is achieved by creating references to the
26 remote branch heads under $GIT_DIR/refs/remotes/origin and by
27 initializing remote.origin.url and remote.origin.fetch configuration
28 variables.
29
31 --local, -l
32 When the repository to clone from is on a local machine, this flag
33 bypasses normal "git aware" transport mechanism and clones the
34 repository by making a copy of HEAD and everything under objects
35 and refs directories. The files under .git/objects/ directory are
36 hardlinked to save space when possible. This is now the default
37 when the source repository is specified with /path/to/repo syntax,
38 so it essentially is a no-op option. To force copying instead of
39 hardlinking (which may be desirable if you are trying to make a
40 back-up of your repository), but still avoid the usual "git aware"
41 transport mechanism, --no-hardlinks can be used.
42
43 --no-hardlinks
44 Optimize the cloning process from a repository on a local
45 filesystem by copying files under .git/objects directory.
46
47 --shared, -s
48 When the repository to clone is on the local machine, instead of
49 using hard links, automatically setup .git/objects/info/alternates
50 to share the objects with the source repository. The resulting
51 repository starts out without any object of its own.
52
53 --reference <repository>
54 If the reference repository is on the local machine automatically
55 setup .git/objects/info/alternates to obtain objects from the
56 reference repository. Using an already existing repository as an
57 alternate will require fewer objects to be copied from the
58 repository being cloned, reducing network and local storage costs.
59
60 --quiet, -q
61 Operate quietly. This flag is passed to "rsync" and
62 "git-fetch-pack" commands when given.
63
64 --no-checkout, -n
65 No checkout of HEAD is performed after the clone is complete.
66
67 --bare
68 Make a bare GIT repository. That is, instead of creating
69 <directory> and placing the administrative files in
70 <directory>/.git, make the <directory> itself the $GIT_DIR. This
71 obviously implies the -n because there is nowhere to check out the
72 working tree. Also the branch heads at the remote are copied
73 directly to corresponding local branch heads, without mapping them
74 to refs/remotes/origin/. When this option is used, neither
75 remote-tracking branches nor the related configuration variables
76 are created.
77
78 --origin <name>, -o <name>
79 Instead of using the remote name origin to keep track of the
80 upstream repository, use <name> instead.
81
82 --upload-pack <upload-pack>, -u <upload-pack>
83 When given, and the repository to clone from is handled by
84 git-fetch-pack, --exec=<upload-pack> is passed to the command to
85 specify non-default path for the command run on the other end.
86
87 --template=<template_directory>
88 Specify the directory from which templates will be used; if unset
89 the templates are taken from the installation defined default,
90 typically /usr/share/git-core/templates.
91
92 --depth <depth>
93 Create a shallow clone with a history truncated to the specified
94 number of revs. A shallow repository has number of limitations (you
95 cannot clone or fetch from it, nor push from nor into it), but is
96 adequate if you want to only look at near the tip of a large
97 project with a long history, and would want to send in a fixes as
98 patches.
99
100 <repository>
101 The (possibly remote) repository to clone from. See the URLS
102 section below for more information on specifying repositories.
103
104 <directory>
105 The name of a new directory to clone into. The "humanish" part of
106 the source repository is used if no directory is explicitly given
107 ("repo" for "/path/to/repo.git" and "foo" for "host.xz:foo/.git").
108 Cloning into an existing directory is not allowed.
109
111 One of the following notations can be used to name the remote
112 repository:
113
114
115 · rsync://host.xz/path/to/repo.git/
116
117 · http://host.xz/path/to/repo.git/
118
119 · https://host.xz/path/to/repo.git/
120
121 · git://host.xz/path/to/repo.git/
122
123 · git://host.xz/~user/path/to/repo.git/
124
125 · ssh://[user@]host.xz[:port]/path/to/repo.git/
126
127 · ssh://[user@]host.xz/path/to/repo.git/
128
129 · ssh://[user@]host.xz/~user/path/to/repo.git/
130
131 · ssh://[user@]host.xz/~/path/to/repo.git
132 SSH is the default transport protocol over the network. You can
133 optionally specify which user to log-in as, and an alternate, scp-like
134 syntax is also supported. Both syntaxes support username expansion, as
135 does the native git protocol, but only the former supports port
136 specification. The following three are identical to the last three
137 above, respectively:
138
139
140 · [user@]host.xz:/path/to/repo.git/
141
142 · [user@]host.xz:~user/path/to/repo.git/
143
144 · [user@]host.xz:path/to/repo.git
145 To sync with a local directory, you can use:
146
147
148 · /path/to/repo.git/
149
150 · file:///path/to/repo.git/
151 They are mostly equivalent, except when cloning. See git-clone(1) for
152 details.
153
155 Clone from upstream
156
157
158 $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
159 $ cd my2.6
160 $ make
161
162
163 Make a local clone that borrows from the current directory, without
164 checking things out
165
166
167 $ git clone -l -s -n . ../copy
168 $ cd ../copy
169 $ git show-branch
170
171
172 Clone from upstream while borrowing from an existing local directory
173
174
175 $ git clone --reference my2.6 \
176 git://git.kernel.org/pub/scm/.../linux-2.7 \
177 my2.7
178 $ cd my2.7
179
180
181 Create a bare repository to publish your changes to the public
182
183
184 $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
185
186
187 Create a repository on the kernel.org machine that borrows from Linus
188
189
190 $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
191 /pub/scm/.../me/subsys-2.6.git
192
193
195 Written by Linus Torvalds <torvalds@osdl.org>
196
198 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
199
201 Part of the git(7) suite
202
203
204
205
206Git 1.5.3.3 10/09/2007 GIT-CLONE(1)