]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-clone.txt
Merge branch 'maint'
[thirdparty/git.git] / Documentation / git-clone.txt
CommitLineData
215a7ad1
JH
1git-clone(1)
2============
6ec311da
JH
3
4NAME
5----
7bd7f280 6git-clone - Clones a repository
6ec311da
JH
7
8
9SYNOPSIS
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>]
b360cca0 14 [--use-separate-remote | --no-separate-remote] <repository>
71821351 15 [<directory>]
6ec311da
JH
16
17DESCRIPTION
18-----------
4607166d
JH
19Clones a repository into a newly created directory. All remote
20branch heads are copied under `$GIT_DIR/refs/heads/`, except
21that the remote `master` is also copied to `origin` branch.
22
23In addition, `$GIT_DIR/remotes/origin` file is set up to have
24this line:
25
26 Pull: master:origin
27
28This is to help the typical workflow of working off of the
29remote `master` branch. Every time `git pull` without argument
30is run, the progress on the remote `master` branch is tracked by
31copying it into the local `origin` branch, and merged into the
95d117b6
JH
32branch you are currently working on. Remote branches other than
33`master` are also added there to be tracked.
4607166d 34
6ec311da
JH
35
36OPTIONS
37-------
a2775c2a 38--local::
6ec311da
JH
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.
46
a2775c2a
EB
47--shared::
48-s::
49 When the repository to clone is on the local machine,
4607166d 50 instead of using hard links, automatically setup
23edecbc 51 .git/objects/info/alternates to share the objects
4607166d
JH
52 with the source repository. The resulting repository
53 starts out without any object of its own.
a2775c2a 54
23edecbc
SP
55--reference <repository>::
56 If the reference repository is on the local machine
57 automatically setup .git/objects/info/alternates to
58 obtain objects from the reference repository. Using
59 an already existing repository as an alternate will
60 require less objects to be copied from the repository
61 being cloned, reducing network and local storage costs.
62
a2775c2a 63--quiet::
6ec311da
JH
64-q::
65 Operate quietly. This flag is passed to "rsync" and
efc7fa53 66 "git-fetch-pack" commands when given.
6ec311da 67
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
80 used, neither the `origin` branch nor the default
81 `remotes/origin` file is created.
8a1a120c 82
ba158a32 83--origin <name>::
e6c310fd
JS
84-o <name>::
85 Instead of using the branch name 'origin' to keep track
86 of the upstream repository, use <name> instead. Note
87 that the shorthand name stored in `remotes/origin` is
88 not affected, but the local branch name to pull the
89 remote `master` branch into is.
90
a2775c2a 91--upload-pack <upload-pack>::
6ec311da
JH
92-u <upload-pack>::
93 When given, and the repository to clone from is handled
efc7fa53 94 by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
6ec311da
JH
95 the command to specify non-default path for the command
96 run on the other end.
97
a57c8bac
JH
98--template=<template_directory>::
99 Specify the directory from which templates will be used;
100 if unset the templates are taken from the installation
101 defined default, typically `/usr/share/git-core/templates`.
102
fb6a9f93 103--use-separate-remote::
f6407823 104 Save remotes heads under `$GIT_DIR/remotes/origin/` instead
71821351
PB
105 of `$GIT_DIR/refs/heads/`. Only the local master branch is
106 saved in the latter. This is the default.
107
b360cca0 108--no-separate-remote::
71821351
PB
109 Save remotes heads in the same namespace as the local
110 heads, `$GIT_DIR/refs/heads/'. In regular repositories,
111 this is a legacy setup git-clone created by default in
112 older Git versions, and will be removed before the next
113 major release.
fb6a9f93 114
6ec311da
JH
115<repository>::
116 The (possibly remote) repository to clone from. It can
4607166d 117 be any URL git-fetch supports.
6ec311da
JH
118
119<directory>::
fb6a9f93 120 The name of a new directory to clone into. The "humanish"
0879aa28
AE
121 part of the source repository is used if no directory is
122 explicitly given ("repo" for "/path/to/repo.git" and "foo"
123 for "host.xz:foo/.git"). Cloning into an existing directory
124 is not allowed.
4607166d 125
1e2ccd3a 126Examples
2b5f3ed3 127--------
1e2ccd3a
JH
128
129Clone from upstream::
130+
131------------
132$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
133$ cd my2.6
134$ make
135------------
136
137
138Make a local clone that borrows from the current directory, without checking things out::
139+
140------------
141$ git clone -l -s -n . ../copy
142$ cd copy
143$ git show-branch
144------------
145
8a1a120c 146
23edecbc
SP
147Clone from upstream while borrowing from an existing local directory::
148+
149------------
150$ git clone --reference my2.6 \
151 git://git.kernel.org/pub/scm/.../linux-2.7 \
152 my2.7
153$ cd my2.7
154------------
155
156
87e80c4b 157Create a bare repository to publish your changes to the public::
8a1a120c
JH
158+
159------------
87e80c4b 160$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
8a1a120c
JH
161------------
162
163
164Create a repository on the kernel.org machine that borrows from Linus::
165+
166------------
87e80c4b 167$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
8a1a120c
JH
168 /pub/scm/.../me/subsys-2.6.git
169------------
170
171
6ec311da
JH
172Author
173------
174Written by Linus Torvalds <torvalds@osdl.org>
175
1e2ccd3a 176
6ec311da
JH
177Documentation
178--------------
0879aa28 179Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
6ec311da
JH
180
181
182GIT
183---
a7154e91 184Part of the gitlink:git[7] suite
6ec311da 185