]>
Commit | Line | Data |
---|---|---|
215a7ad1 JH |
1 | git-clone(1) |
2 | ============ | |
6ec311da JH |
3 | |
4 | NAME | |
5 | ---- | |
7bd7f280 | 6 | git-clone - Clones a repository |
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>] | |
63085fab | 14 | <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 | |
21 | (visible using `git branch -r`), and creates and checks out a master | |
22 | branch equal to the cloned repository's master 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 | |
27 | current branch. | |
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 JH |
33 | |
34 | OPTIONS | |
35 | ------- | |
a2775c2a | 36 | --local:: |
6ec311da JH |
37 | -l:: |
38 | When the repository to clone from is on a local machine, | |
39 | this flag bypasses normal "git aware" transport | |
40 | mechanism and clones the repository by making a copy of | |
41 | HEAD and everything under objects and refs directories. | |
42 | The files under .git/objects/ directory are hardlinked | |
43 | to save space when possible. | |
44 | ||
a2775c2a EB |
45 | --shared:: |
46 | -s:: | |
47 | When the repository to clone is on the local machine, | |
4607166d | 48 | instead of using hard links, automatically setup |
23edecbc | 49 | .git/objects/info/alternates to share the objects |
4607166d JH |
50 | with the source repository. The resulting repository |
51 | starts out without any object of its own. | |
a2775c2a | 52 | |
23edecbc SP |
53 | --reference <repository>:: |
54 | If the reference repository is on the local machine | |
55 | automatically setup .git/objects/info/alternates to | |
56 | obtain objects from the reference repository. Using | |
57 | an already existing repository as an alternate will | |
58 | require less objects to be copied from the repository | |
59 | being cloned, reducing network and local storage costs. | |
60 | ||
a2775c2a | 61 | --quiet:: |
6ec311da JH |
62 | -q:: |
63 | Operate quietly. This flag is passed to "rsync" and | |
efc7fa53 | 64 | "git-fetch-pack" commands when given. |
6ec311da | 65 | |
a2775c2a EB |
66 | -n:: |
67 | No checkout of HEAD is performed after the clone is complete. | |
68 | ||
87e80c4b JH |
69 | --bare:: |
70 | Make a 'bare' GIT repository. That is, instead of | |
8a1a120c JH |
71 | creating `<directory>` and placing the administrative |
72 | files in `<directory>/.git`, make the `<directory>` | |
71821351 PB |
73 | itself the `$GIT_DIR`. This obviously implies the `-n` |
74 | because there is nowhere to check out the working tree. | |
75 | Also the branch heads at the remote are copied directly | |
76 | to corresponding local branch heads, without mapping | |
77 | them to `refs/remotes/origin/`. When this option is | |
78 | used, neither the `origin` branch nor the default | |
79 | `remotes/origin` file is created. | |
8a1a120c | 80 | |
ba158a32 | 81 | --origin <name>:: |
e6c310fd JS |
82 | -o <name>:: |
83 | Instead of using the branch name 'origin' to keep track | |
84 | of the upstream repository, use <name> instead. Note | |
85 | that the shorthand name stored in `remotes/origin` is | |
86 | not affected, but the local branch name to pull the | |
87 | remote `master` branch into is. | |
88 | ||
a2775c2a | 89 | --upload-pack <upload-pack>:: |
6ec311da JH |
90 | -u <upload-pack>:: |
91 | When given, and the repository to clone from is handled | |
efc7fa53 | 92 | by 'git-fetch-pack', '--exec=<upload-pack>' is passed to |
6ec311da JH |
93 | the command to specify non-default path for the command |
94 | run on the other end. | |
95 | ||
a57c8bac JH |
96 | --template=<template_directory>:: |
97 | Specify the directory from which templates will be used; | |
98 | if unset the templates are taken from the installation | |
99 | defined default, typically `/usr/share/git-core/templates`. | |
100 | ||
6ec311da JH |
101 | <repository>:: |
102 | The (possibly remote) repository to clone from. It can | |
4607166d | 103 | be any URL git-fetch supports. |
6ec311da JH |
104 | |
105 | <directory>:: | |
fb6a9f93 | 106 | The name of a new directory to clone into. The "humanish" |
0879aa28 AE |
107 | part of the source repository is used if no directory is |
108 | explicitly given ("repo" for "/path/to/repo.git" and "foo" | |
109 | for "host.xz:foo/.git"). Cloning into an existing directory | |
110 | is not allowed. | |
4607166d | 111 | |
1e2ccd3a | 112 | Examples |
2b5f3ed3 | 113 | -------- |
1e2ccd3a JH |
114 | |
115 | Clone from upstream:: | |
116 | + | |
117 | ------------ | |
118 | $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6 | |
119 | $ cd my2.6 | |
120 | $ make | |
121 | ------------ | |
122 | ||
123 | ||
124 | Make a local clone that borrows from the current directory, without checking things out:: | |
125 | + | |
126 | ------------ | |
127 | $ git clone -l -s -n . ../copy | |
128 | $ cd copy | |
129 | $ git show-branch | |
130 | ------------ | |
131 | ||
8a1a120c | 132 | |
23edecbc SP |
133 | Clone from upstream while borrowing from an existing local directory:: |
134 | + | |
135 | ------------ | |
136 | $ git clone --reference my2.6 \ | |
137 | git://git.kernel.org/pub/scm/.../linux-2.7 \ | |
138 | my2.7 | |
139 | $ cd my2.7 | |
140 | ------------ | |
141 | ||
142 | ||
87e80c4b | 143 | Create a bare repository to publish your changes to the public:: |
8a1a120c JH |
144 | + |
145 | ------------ | |
87e80c4b | 146 | $ git clone --bare -l /home/proj/.git /pub/scm/proj.git |
8a1a120c JH |
147 | ------------ |
148 | ||
149 | ||
150 | Create a repository on the kernel.org machine that borrows from Linus:: | |
151 | + | |
152 | ------------ | |
87e80c4b | 153 | $ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \ |
8a1a120c JH |
154 | /pub/scm/.../me/subsys-2.6.git |
155 | ------------ | |
156 | ||
157 | ||
6ec311da JH |
158 | Author |
159 | ------ | |
160 | Written by Linus Torvalds <torvalds@osdl.org> | |
161 | ||
1e2ccd3a | 162 | |
6ec311da JH |
163 | Documentation |
164 | -------------- | |
0879aa28 | 165 | Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. |
6ec311da JH |
166 | |
167 | ||
168 | GIT | |
169 | --- | |
a7154e91 | 170 | Part of the gitlink:git[7] suite |
6ec311da | 171 |