blob: 6d32c491a591daa183424a8743ed119e07631b27 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-clone(1)
2============
3
4NAME
5----
Junio C Hamano7c73c662007-01-19 00:37:506git-clone - Clones a repository into a new directory
Junio C Hamano1a4e8412005-12-27 08:17:237
8
9SYNOPSIS
10--------
Junio C Hamano235a91e2006-01-07 01:13:5811[verse]
Junio C Hamanof31d9f52006-05-28 20:58:0912'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
13 [-o <name>] [-u <upload-pack>] [--reference <repository>]
Junio C Hamano0bbd4672007-02-20 04:52:1414 [--depth <depth>] <repository> [<directory>]
Junio C Hamano1a4e8412005-12-27 08:17:2315
16DESCRIPTION
17-----------
Junio C Hamano1a4e8412005-12-27 08:17:2318
Junio C Hamano5102d9a2006-12-08 07:23:4619Clones a repository into a newly created directory, creates
20remote-tracking branches for each branch in the cloned repository
Junio C Hamano79770b62007-01-07 07:43:5821(visible using `git branch -r`), and creates and checks out an initial
22branch equal to the cloned repository's currently active branch.
Junio C Hamano1a4e8412005-12-27 08:17:2323
Junio C Hamano5102d9a2006-12-08 07:23:4624After the clone, a plain `git fetch` without arguments will update
25all the remote-tracking branches, and a `git pull` without
26arguments will in addition merge the remote master branch into the
Junio C Hamano79770b62007-01-07 07:43:5827current master branch, if any.
Junio C Hamano1a4e8412005-12-27 08:17:2328
Junio C Hamano5102d9a2006-12-08 07:23:4629This default configuration is achieved by creating references to
30the remote branch heads under `$GIT_DIR/refs/remotes/origin` and
31by initializing `remote.origin.url` and `remote.origin.fetch`
32configuration variables.
Junio C Hamano1a4e8412005-12-27 08:17:2333
Junio C Hamanob288d9e2007-01-02 00:04:1534
Junio C Hamano1a4e8412005-12-27 08:17:2335OPTIONS
36-------
37--local::
38-l::
39When the repository to clone from is on a local machine,
40this flag bypasses normal "git aware" transport
41mechanism and clones the repository by making a copy of
42HEAD and everything under objects and refs directories.
43The files under .git/objects/ directory are hardlinked
44to save space when possible.
45
46--shared::
47-s::
48When the repository to clone is on the local machine,
49instead of using hard links, automatically setup
Junio C Hamanof50bfec2006-04-19 09:44:1250.git/objects/info/alternates to share the objects
Junio C Hamano1a4e8412005-12-27 08:17:2351with the source repository. The resulting repository
52starts out without any object of its own.
53
Junio C Hamanof50bfec2006-04-19 09:44:1254--reference <repository>::
55If the reference repository is on the local machine
56automatically setup .git/objects/info/alternates to
57obtain objects from the reference repository. Using
58an already existing repository as an alternate will
59require less objects to be copied from the repository
60being cloned, reducing network and local storage costs.
61
Junio C Hamano1a4e8412005-12-27 08:17:2362--quiet::
63-q::
64Operate quietly. This flag is passed to "rsync" and
Junio C Hamano97f518c2006-06-22 19:49:3565"git-fetch-pack" commands when given.
Junio C Hamano1a4e8412005-12-27 08:17:2366
67-n::
68No checkout of HEAD is performed after the clone is complete.
69
Junio C Hamanoe663a7a2006-01-25 12:37:2870--bare::
71Make a 'bare' GIT repository. That is, instead of
Junio C Hamano38064d52006-01-15 10:13:4972creating `<directory>` and placing the administrative
73files in `<directory>/.git`, make the `<directory>`
Junio C Hamano9f292e72006-11-24 11:37:2974itself the `$GIT_DIR`. This obviously implies the `-n`
75because there is nowhere to check out the working tree.
76Also the branch heads at the remote are copied directly
77to corresponding local branch heads, without mapping
78them to `refs/remotes/origin/`. When this option is
Junio C Hamanod3361ad2007-01-01 03:20:2479used, neither remote-tracking branches nor the related
80configuration variables are created.
Junio C Hamano38064d52006-01-15 10:13:4981
Junio C Hamanodcc22ee2006-11-03 02:40:1382--origin <name>::
Junio C Hamano1a4e8412005-12-27 08:17:2383-o <name>::
Junio C Hamanod3361ad2007-01-01 03:20:2484Instead of using the remote name 'origin' to keep track
85of the upstream repository, use <name> instead.
Junio C Hamano1a4e8412005-12-27 08:17:2386
87--upload-pack <upload-pack>::
88-u <upload-pack>::
89When given, and the repository to clone from is handled
Junio C Hamano97f518c2006-06-22 19:49:3590by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
Junio C Hamano1a4e8412005-12-27 08:17:2391the command to specify non-default path for the command
92run on the other end.
93
Junio C Hamanof31d9f52006-05-28 20:58:0994--template=<template_directory>::
95Specify the directory from which templates will be used;
96if unset the templates are taken from the installation
97defined default, typically `/usr/share/git-core/templates`.
98
Junio C Hamano0bbd4672007-02-20 04:52:1499--depth <depth>::
Junio C Hamanob288d9e2007-01-02 00:04:15100Create a 'shallow' clone with a history truncated to the
101specified number of revs. A shallow repository has
102number of limitations (you cannot clone or fetch from
103it, nor push from nor into it), but is adequate if you
104want to only look at near the tip of a large project
105with a long history, and would want to send in a fixes
106as patches.
107
Junio C Hamano1a4e8412005-12-27 08:17:23108<repository>::
109The (possibly remote) repository to clone from. It can
110be any URL git-fetch supports.
111
112<directory>::
Junio C Hamano8db10ef2006-06-09 04:31:57113The name of a new directory to clone into. The "humanish"
Junio C Hamano1a4e8412005-12-27 08:17:23114part of the source repository is used if no directory is
115explicitly given ("repo" for "/path/to/repo.git" and "foo"
116for "host.xz:foo/.git"). Cloning into an existing directory
117is not allowed.
118
119Examples
Junio C Hamano1bb569e2006-05-05 23:14:25120--------
Junio C Hamano1a4e8412005-12-27 08:17:23121
122Clone from upstream::
123+
124------------
125$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
126$ cd my2.6
127$ make
128------------
129
130
131Make a local clone that borrows from the current directory, without checking things out::
132+
133------------
134$ git clone -l -s -n . ../copy
135$ cd copy
136$ git show-branch
137------------
138
Junio C Hamano38064d52006-01-15 10:13:49139
Junio C Hamanof50bfec2006-04-19 09:44:12140Clone from upstream while borrowing from an existing local directory::
141+
142------------
143$ git clone --reference my2.6 \
144git://git.kernel.org/pub/scm/.../linux-2.7 \
145my2.7
146$ cd my2.7
147------------
148
149
Junio C Hamanoe663a7a2006-01-25 12:37:28150Create a bare repository to publish your changes to the public::
Junio C Hamano38064d52006-01-15 10:13:49151+
152------------
Junio C Hamanoe663a7a2006-01-25 12:37:28153$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
Junio C Hamano38064d52006-01-15 10:13:49154------------
155
156
157Create a repository on the kernel.org machine that borrows from Linus::
158+
159------------
Junio C Hamanoe663a7a2006-01-25 12:37:28160$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
Junio C Hamano38064d52006-01-15 10:13:49161 /pub/scm/.../me/subsys-2.6.git
162------------
163
164
Junio C Hamano1a4e8412005-12-27 08:17:23165Author
166------
167Written by Linus Torvalds <torvalds@osdl.org>
168
169
170Documentation
171--------------
172Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
173
174
175GIT
176---
177Part of the gitlink:git[7] suite
178