]>
Commit | Line | Data |
---|---|---|
215a7ad1 JH |
1 | git-clone(1) |
2 | ============ | |
6ec311da JH |
3 | |
4 | NAME | |
5 | ---- | |
29cf5e12 | 6 | git-clone - Clone a repository into a new directory |
6ec311da JH |
7 | |
8 | ||
9 | SYNOPSIS | |
10 | -------- | |
353ce815 | 11 | [verse] |
a57c8bac JH |
12 | 'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare] |
13 | [-o <name>] [-u <upload-pack>] [--reference <repository>] | |
f496454e | 14 | [--depth <depth>] <repository> [<directory>] |
6ec311da JH |
15 | |
16 | DESCRIPTION | |
17 | ----------- | |
4607166d | 18 | |
db9819a4 BF |
19 | Clones a repository into a newly created directory, creates |
20 | remote-tracking branches for each branch in the cloned repository | |
1170e802 SG |
21 | (visible using `git branch -r`), and creates and checks out an initial |
22 | branch equal to the cloned repository's currently active branch. | |
4607166d | 23 | |
db9819a4 BF |
24 | After the clone, a plain `git fetch` without arguments will update |
25 | all the remote-tracking branches, and a `git pull` without | |
26 | arguments will in addition merge the remote master branch into the | |
1170e802 | 27 | current master branch, if any. |
4607166d | 28 | |
db9819a4 BF |
29 | This default configuration is achieved by creating references to |
30 | the remote branch heads under `$GIT_DIR/refs/remotes/origin` and | |
31 | by initializing `remote.origin.url` and `remote.origin.fetch` | |
32 | configuration variables. | |
6ec311da | 33 | |
f4bf2184 | 34 | |
6ec311da JH |
35 | OPTIONS |
36 | ------- | |
a2775c2a | 37 | --local:: |
6ec311da JH |
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. | |
45 | ||
a2775c2a EB |
46 | --shared:: |
47 | -s:: | |
48 | When the repository to clone is on the local machine, | |
4607166d | 49 | instead of using hard links, automatically setup |
23edecbc | 50 | .git/objects/info/alternates to share the objects |
4607166d JH |
51 | with the source repository. The resulting repository |
52 | starts out without any object of its own. | |
a2775c2a | 53 | |
23edecbc SP |
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. | |
61 | ||
a2775c2a | 62 | --quiet:: |
6ec311da JH |
63 | -q:: |
64 | Operate quietly. This flag is passed to "rsync" and | |
efc7fa53 | 65 | "git-fetch-pack" commands when given. |
6ec311da | 66 | |
fd0368f9 | 67 | --no-checkout:: |
a2775c2a EB |
68 | -n:: |
69 | No checkout of HEAD is performed after the clone is complete. | |
70 | ||
87e80c4b JH |
71 | --bare:: |
72 | Make a 'bare' GIT repository. That is, instead of | |
8a1a120c JH |
73 | creating `<directory>` and placing the administrative |
74 | files in `<directory>/.git`, make the `<directory>` | |
71821351 PB |
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 | |
36566cc0 BF |
80 | used, neither remote-tracking branches nor the related |
81 | configuration variables are created. | |
8a1a120c | 82 | |
ba158a32 | 83 | --origin <name>:: |
e6c310fd | 84 | -o <name>:: |
36566cc0 BF |
85 | Instead of using the remote name 'origin' to keep track |
86 | of the upstream repository, use <name> instead. | |
e6c310fd | 87 | |
a2775c2a | 88 | --upload-pack <upload-pack>:: |
6ec311da JH |
89 | -u <upload-pack>:: |
90 | When given, and the repository to clone from is handled | |
efc7fa53 | 91 | by 'git-fetch-pack', '--exec=<upload-pack>' is passed to |
6ec311da JH |
92 | the command to specify non-default path for the command |
93 | run on the other end. | |
94 | ||
a57c8bac JH |
95 | --template=<template_directory>:: |
96 | Specify the directory from which templates will be used; | |
97 | if unset the templates are taken from the installation | |
98 | defined default, typically `/usr/share/git-core/templates`. | |
99 | ||
f496454e | 100 | --depth <depth>:: |
f4bf2184 JH |
101 | Create a 'shallow' clone with a history truncated to the |
102 | specified number of revs. A shallow repository has | |
103 | number of limitations (you cannot clone or fetch from | |
104 | it, nor push from nor into it), but is adequate if you | |
105 | want to only look at near the tip of a large project | |
106 | with a long history, and would want to send in a fixes | |
107 | as patches. | |
108 | ||
6ec311da | 109 | <repository>:: |
37ba0561 AR |
110 | The (possibly remote) repository to clone from. See the |
111 | <<URLS,URLS>> section below for more information on specifying | |
112 | repositories. | |
6ec311da JH |
113 | |
114 | <directory>:: | |
fb6a9f93 | 115 | The name of a new directory to clone into. The "humanish" |
0879aa28 AE |
116 | part of the source repository is used if no directory is |
117 | explicitly given ("repo" for "/path/to/repo.git" and "foo" | |
118 | for "host.xz:foo/.git"). Cloning into an existing directory | |
119 | is not allowed. | |
4607166d | 120 | |
37ba0561 AR |
121 | include::urls.txt[] |
122 | ||
1e2ccd3a | 123 | Examples |
2b5f3ed3 | 124 | -------- |
1e2ccd3a JH |
125 | |
126 | Clone from upstream:: | |
127 | + | |
128 | ------------ | |
129 | $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6 | |
130 | $ cd my2.6 | |
131 | $ make | |
132 | ------------ | |
133 | ||
134 | ||
135 | Make a local clone that borrows from the current directory, without checking things out:: | |
136 | + | |
137 | ------------ | |
138 | $ git clone -l -s -n . ../copy | |
a6e3768f | 139 | $ cd ../copy |
1e2ccd3a JH |
140 | $ git show-branch |
141 | ------------ | |
142 | ||
8a1a120c | 143 | |
23edecbc SP |
144 | Clone from upstream while borrowing from an existing local directory:: |
145 | + | |
146 | ------------ | |
147 | $ git clone --reference my2.6 \ | |
148 | git://git.kernel.org/pub/scm/.../linux-2.7 \ | |
149 | my2.7 | |
150 | $ cd my2.7 | |
151 | ------------ | |
152 | ||
153 | ||
87e80c4b | 154 | Create a bare repository to publish your changes to the public:: |
8a1a120c JH |
155 | + |
156 | ------------ | |
87e80c4b | 157 | $ git clone --bare -l /home/proj/.git /pub/scm/proj.git |
8a1a120c JH |
158 | ------------ |
159 | ||
160 | ||
161 | Create a repository on the kernel.org machine that borrows from Linus:: | |
162 | + | |
163 | ------------ | |
87e80c4b | 164 | $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \ |
8a1a120c JH |
165 | /pub/scm/.../me/subsys-2.6.git |
166 | ------------ | |
167 | ||
168 | ||
6ec311da JH |
169 | Author |
170 | ------ | |
171 | Written by Linus Torvalds <torvalds@osdl.org> | |
172 | ||
1e2ccd3a | 173 | |
6ec311da JH |
174 | Documentation |
175 | -------------- | |
0879aa28 | 176 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. |
6ec311da JH |
177 | |
178 | ||
179 | GIT | |
180 | --- | |
a7154e91 | 181 | Part of the gitlink:git[7] suite |