blob: 5de18de2ab83fef4fffdb95348adddec02d1fcfa [file] [log] [blame]
Junio C Hamano215a7ad2005-09-07 17:26:23 -07001git-clone(1)
2============
Junio C Hamano6ec311d2005-07-13 20:25:54 -07003
4NAME
5----
william pursell29cf5e12007-06-09 16:44:12 +01006git-clone - Clone a repository into a new directory
Junio C Hamano6ec311d2005-07-13 20:25:54 -07007
8
9SYNOPSIS
10--------
Jonas Fonseca353ce812005-12-31 18:37:15 +010011[verse]
Jean-Noël Avila76880f02024-03-29 11:19:40 +000012`git clone` [++--template=++__<template-directory>__]
13 [`-l`] [`-s`] [`--no-hardlinks`] [`-q`] [`-n`] [`--bare`] [`--mirror`]
14 [`-o` _<name>_] [`-b` _<name>_] [`-u` _<upload-pack>_] [`--reference` _<repository>_]
15 [`--dissociate`] [`--separate-git-dir` _<git-dir>_]
16 [`--depth` _<depth>_] [`--`[`no-`]`single-branch`] [`--no-tags`]
17 [++--recurse-submodules++[++=++__<pathspec>__]] [`--`[`no-`]`shallow-submodules`]
18 [`--`[`no-`]`remote-submodules`] [`--jobs` _<n>_] [`--sparse`] [`--`[`no-`]`reject-shallow`]
19 [++--filter=++__<filter-spec>__] [`--also-filter-submodules`]] [`--`] _<repository>_
20 [_<directory>_]
Junio C Hamano6ec311d2005-07-13 20:25:54 -070021
22DESCRIPTION
23-----------
Junio C Hamano46071662005-11-05 22:26:52 -080024
J. Bruce Fieldsdb9819a2006-12-08 01:27:21 -050025Clones a repository into a newly created directory, creates
26remote-tracking branches for each branch in the cloned repository
Quentin Nerden3711d1c2019-07-02 07:37:40 -070027(visible using `git branch --remotes`), and creates and checks out an
Jonathan Nieder33405be2009-10-09 18:07:39 -050028initial branch that is forked from the cloned repository's
29currently active branch.
Junio C Hamano46071662005-11-05 22:26:52 -080030
J. Bruce Fieldsdb9819a2006-12-08 01:27:21 -050031After the clone, a plain `git fetch` without arguments will update
32all the remote-tracking branches, and a `git pull` without
33arguments will in addition merge the remote master branch into the
Jean-Noël Avila76880f02024-03-29 11:19:40 +000034current master branch, if any (this is untrue when `--single-branch`
Ralf Thielow31b808a2012-09-20 20:04:08 +020035is given; see below).
Junio C Hamano46071662005-11-05 22:26:52 -080036
J. Bruce Fieldsdb9819a2006-12-08 01:27:21 -050037This default configuration is achieved by creating references to
Jeff Kingcc1b8d82010-02-17 20:16:20 -050038the remote branch heads under `refs/remotes/origin` and
J. Bruce Fieldsdb9819a2006-12-08 01:27:21 -050039by initializing `remote.origin.url` and `remote.origin.fetch`
40configuration variables.
Junio C Hamano6ec311d2005-07-13 20:25:54 -070041
Junio C Hamanof4bf2182007-01-01 15:08:06 -080042
Junio C Hamano6ec311d2005-07-13 20:25:54 -070043OPTIONS
44-------
Jean-Noël Avila76880f02024-03-29 11:19:40 +000045`-l`::
46`--local`::
Junio C Hamano6ec311d2005-07-13 20:25:54 -070047 When the repository to clone from is on a local machine,
Thomas Ackermann2de9b712013-01-21 20:17:53 +010048 this flag bypasses the normal "Git aware" transport
Junio C Hamano6ec311d2005-07-13 20:25:54 -070049 mechanism and clones the repository by making a copy of
Jean-Noël Avila76880f02024-03-29 11:19:40 +000050 `HEAD` and everything under objects and refs directories.
Junio C Hamano3d5c4182007-08-01 23:42:36 -070051 The files under `.git/objects/` directory are hardlinked
Jeff King9197a102012-05-30 07:09:08 -040052 to save space when possible.
53+
54If the repository is specified as a local path (e.g., `/path/to/repo`),
55this is the default, and --local is essentially a no-op. If the
56repository is specified as a URL, then this flag is ignored (and we
Jeff King189260b2012-05-30 07:10:16 -040057never use the local optimizations). Specifying `--no-local` will
58override the default when `/path/to/repo` is given, using the regular
Thomas Ackermann2de9b712013-01-21 20:17:53 +010059Git transport instead.
Taylor Blaua4a1ca22021-01-11 14:25:10 -050060+
Glen Choo4e335352023-04-10 22:18:50 +000061If the repository's `$GIT_DIR/objects` has symbolic links or is a
62symbolic link, the clone will fail. This is a security measure to
63prevent the unintentional copying of files by dereferencing the symbolic
64links.
65+
Taylor Blaua4a1ca22021-01-11 14:25:10 -050066*NOTE*: this operation can race with concurrent modification to the
67source repository, similar to running `cp -r src dst` while modifying
68`src`.
Junio C Hamano3d5c4182007-08-01 23:42:36 -070069
Jean-Noël Avila76880f02024-03-29 11:19:40 +000070`--no-hardlinks`::
Albert L. Lash, IV897e3e42014-02-08 15:41:36 -050071 Force the cloning process from a repository on a local
72 filesystem to copy the files under the `.git/objects`
73 directory instead of using hardlinks. This may be desirable
74 if you are trying to make a back-up of your repository.
Junio C Hamano6ec311d2005-07-13 20:25:54 -070075
Jean-Noël Avila76880f02024-03-29 11:19:40 +000076`-s`::
77`--shared`::
Eric W. Biedermana2775c22005-10-02 13:42:57 -060078 When the repository to clone is on the local machine,
Junio C Hamano46071662005-11-05 22:26:52 -080079 instead of using hard links, automatically setup
Björn Gustavsson550c66f2009-10-20 22:38:38 +020080 `.git/objects/info/alternates` to share the objects
Junio C Hamano46071662005-11-05 22:26:52 -080081 with the source repository. The resulting repository
82 starts out without any object of its own.
Miklos Vajna84668872008-02-12 01:12:57 +010083+
84*NOTE*: this is a possibly dangerous operation; do *not* use
85it unless you understand what it does. If you clone your
Brandon Casey2498a1a2008-04-03 13:26:13 -050086repository using this option and then delete branches (or use any
Thomas Ackermann2de9b712013-01-21 20:17:53 +010087other Git command that makes any existing commit unreferenced) in the
Brandon Casey2498a1a2008-04-03 13:26:13 -050088source repository, some objects may become unreferenced (or dangling).
Thomas Ackermann2de9b712013-01-21 20:17:53 +010089These objects may be removed by normal Git operations (such as `git commit`)
Derrick Stoleea95ce122020-09-17 18:11:44 +000090which automatically call `git maintenance run --auto`. (See
91linkgit:git-maintenance[1].) If these objects are removed and were referenced
92by the cloned repository, then the cloned repository will become corrupt.
Jeff King13354f52009-08-17 02:19:17 -040093+
Quentin Nerden3711d1c2019-07-02 07:37:40 -070094Note that running `git repack` without the `--local` option in a repository
95cloned with `--shared` will copy objects from the source repository into a pack
96in the cloned repository, removing the disk space savings of `clone --shared`.
97It is safe, however, to run `git gc`, which uses the `--local` option by
Jeff King13354f52009-08-17 02:19:17 -040098default.
99+
Quentin Nerden3711d1c2019-07-02 07:37:40 -0700100If you want to break the dependency of a repository cloned with `--shared` on
Jeff King13354f52009-08-17 02:19:17 -0400101its source repository, you can simply run `git repack -a` to copy all
102objects from the source repository into a pack in the cloned repository.
Eric W. Biedermana2775c22005-10-02 13:42:57 -0600103
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000104`--reference`[`-if-able`] _<repository>_::
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000105 If the reference _<repository>_ is on the local machine,
Björn Gustavsson550c66f2009-10-20 22:38:38 +0200106 automatically setup `.git/objects/info/alternates` to
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000107 obtain objects from the reference _<repository>_. Using
Shawn Pearce23edecb2006-04-18 20:19:48 -0400108 an already existing repository as an alternate will
Mike Ralphson451e5932007-09-07 17:43:37 +0100109 require fewer objects to be copied from the repository
Shawn Pearce23edecb2006-04-18 20:19:48 -0400110 being cloned, reducing network and local storage costs.
Stefan Bellerf7415b42016-08-15 14:53:26 -0700111 When using the `--reference-if-able`, a non existing
112 directory is skipped with a warning instead of aborting
113 the clone.
Brandon Casey2498a1a2008-04-03 13:26:13 -0500114+
Junio C Hamanofb1d6da2014-10-14 12:38:52 -0700115*NOTE*: see the NOTE for the `--shared` option, and also the
116`--dissociate` option.
117
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000118`--dissociate`::
Junio C Hamanofb1d6da2014-10-14 12:38:52 -0700119 Borrow the objects from reference repositories specified
120 with the `--reference` options only to reduce network
Alex Riesen01816812015-10-22 18:41:17 +0200121 transfer, and stop borrowing from them after a clone is made
122 by making necessary local copies of borrowed objects. This
123 option can also be used when cloning locally from a
124 repository that already borrows objects from another
125 repository--the new repository will borrow objects from the
126 same repository, and this option can be used to stop the
127 borrowing.
Shawn Pearce23edecb2006-04-18 20:19:48 -0400128
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000129`-q`::
130`--quiet`::
Tay Ray Chuan488c3162009-12-26 01:12:04 +0800131 Operate quietly. Progress is not reported to the standard
Jeff King0d0bac62016-01-30 02:21:26 -0500132 error stream.
Junio C Hamano6ec311d2005-07-13 20:25:54 -0700133
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000134`-v`::
135`--verbose`::
Tay Ray Chuanc54b74a2010-02-24 20:50:20 +0800136 Run verbosely. Does not affect the reporting of progress status
137 to the standard error stream.
Tay Ray Chuan5a518ad2009-12-26 01:12:06 +0800138
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000139`--progress`::
Tay Ray Chuan488c3162009-12-26 01:12:04 +0800140 Progress status is reported on the standard error stream
Quentin Nerden3711d1c2019-07-02 07:37:40 -0700141 by default when it is attached to a terminal, unless `--quiet`
Tay Ray Chuan488c3162009-12-26 01:12:04 +0800142 is specified. This flag forces progress status even if the
143 standard error stream is not directed to a terminal.
Miklos Vajna21188b12008-10-09 01:40:32 +0200144
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000145++--server-option=++__<option>__::
Jonathan Tan6e983052019-04-12 12:51:22 -0700146 Transmit the given string to the server when communicating using
147 protocol version 2. The given string must not contain a NUL or LF
148 character. The server's handling of server options, including
149 unknown ones, is server-specific.
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000150 When multiple ++--server-option=++__<option>__ are given, they are all
Jonathan Tan6e983052019-04-12 12:51:22 -0700151 sent to the other side in the order listed on the command line.
152
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000153`-n`::
154`--no-checkout`::
Eric W. Biedermana2775c22005-10-02 13:42:57 -0600155 No checkout of HEAD is performed after the clone is complete.
156
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000157`--`[`no-`]`reject-shallow`::
Li Linchao4fe788b2021-04-01 10:46:59 +0000158 Fail if the source repository is a shallow repository.
Jean-Noël Avilad3717e12024-03-10 19:10:29 +0000159 The `clone.rejectShallow` configuration variable can be used to
Li Linchao4fe788b2021-04-01 10:46:59 +0000160 specify the default.
161
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000162`--bare`::
Thomas Ackermann48a8c262013-01-21 20:16:20 +0100163 Make a 'bare' Git repository. That is, instead of
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000164 creating _<directory>_ and placing the administrative
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000165 files in _<directory>_`/.git`, make the _<directory>_
Quentin Nerden3711d1c2019-07-02 07:37:40 -0700166 itself the `$GIT_DIR`. This obviously implies the `--no-checkout`
Petr Baudis71821352006-11-23 23:58:35 +0100167 because there is nowhere to check out the working tree.
168 Also the branch heads at the remote are copied directly
169 to corresponding local branch heads, without mapping
170 them to `refs/remotes/origin/`. When this option is
J. Bruce Fields36566cc2006-12-31 18:47:34 -0500171 used, neither remote-tracking branches nor the related
172 configuration variables are created.
Junio C Hamano8a1a1202006-01-14 16:00:32 -0800173
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000174`--sparse`::
Elijah Newrend30e2bb2021-12-14 04:09:11 +0000175 Employ a sparse-checkout, with only files in the toplevel
176 directory initially being present. The
177 linkgit:git-sparse-checkout[1] command can be used to grow the
178 working directory as needed.
Derrick Stoleed89f09c2019-11-21 22:04:35 +0000179
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000180++--filter=++__<filter-spec>__::
Derrick Stolee4a465442020-03-22 19:50:06 +0000181 Use the partial clone feature and request that the server sends
182 a subset of reachable objects according to a given object filter.
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000183 When using `--filter`, the supplied _<filter-spec>_ is used for
Derrick Stolee4a465442020-03-22 19:50:06 +0000184 the partial clone filter. For example, `--filter=blob:none` will
185 filter out all blobs (file contents) until needed by Git. Also,
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000186 ++--filter=blob:limit=++__<size>__ will filter out all blobs of size
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000187 at least _<size>_. For more details on filter specifications, see
Derrick Stolee4a465442020-03-22 19:50:06 +0000188 the `--filter` option in linkgit:git-rev-list[1].
189
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000190`--also-filter-submodules`::
Josh Steadmonf05da2b2022-02-04 21:00:49 -0800191 Also apply the partial clone filter to any submodules in the repository.
192 Requires `--filter` and `--recurse-submodules`. This can be turned on by
193 default by setting the `clone.filterSubmodules` config option.
194
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000195`--mirror`::
Uwe Kleine-König6db21032010-10-04 19:28:27 +0200196 Set up a mirror of the source repository. This implies `--bare`.
197 Compared to `--bare`, `--mirror` not only maps local branches of the
198 source to local branches of the target, it maps all refs (including
Matthieu Moy29b9a662010-11-02 16:31:24 +0100199 remote-tracking branches, notes etc.) and sets up a refspec configuration such
Uwe Kleine-König6db21032010-10-04 19:28:27 +0200200 that all these refs are overwritten by a `git remote update` in the
201 target repository.
Johannes Schindelinbc699af2008-08-02 21:38:56 +0200202
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000203`-o` _<name>_::
204`--origin` _<name>_::
Sean Baragde9ed3e2020-10-01 03:46:16 +0000205 Instead of using the remote name `origin` to keep track of the upstream
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000206 repository, use _<name>_. Overrides `clone.defaultRemoteName` from the
Sean Baragde9ed3e2020-10-01 03:46:16 +0000207 config.
Johannes Schindeline6c310f2005-12-22 23:37:24 +0100208
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000209`-b` _<name>_::
210`--branch` _<name>_::
Jeff King7a4ee282009-08-26 15:05:08 -0400211 Instead of pointing the newly created HEAD to the branch pointed
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000212 to by the cloned repository's HEAD, point to _<name>_ branch
Ralf Thielow31b808a2012-09-20 20:04:08 +0200213 instead. In a non-bare repository, this is the branch that will
214 be checked out.
215 `--branch` can also take tags and detaches the HEAD at that commit
216 in the resulting repository.
Jeff King7a4ee282009-08-26 15:05:08 -0400217
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000218`-u` _<upload-pack>_::
219`--upload-pack` _<upload-pack>_::
Steve Haslamd3296e32008-07-25 19:37:48 +0100220 When given, and the repository to clone from is accessed
221 via ssh, this specifies a non-default path for the command
Junio C Hamano6ec311d2005-07-13 20:25:54 -0700222 run on the other end.
223
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000224++--template=++__<template-directory>__::
Junio C Hamanoa57c8ba2006-05-28 10:14:38 -0700225 Specify the directory from which templates will be used;
Steven Draked8a84882010-02-17 12:44:46 +1300226 (See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].)
Junio C Hamanoa57c8ba2006-05-28 10:14:38 -0700227
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000228`-c` __<key>__++=++__<value>__::
229`--config` __<key>__++=++__<value>__::
Jeff King84054f72011-06-09 16:56:19 -0400230 Set a configuration variable in the newly-created repository;
231 this takes effect immediately after the repository is
232 initialized, but before the remote history is fetched or any
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000233 files checked out. The _<key>_ is in the same format as expected by
Jeff King84054f72011-06-09 16:56:19 -0400234 linkgit:git-config[1] (e.g., `core.eol=true`). If multiple
235 values are given for the same key, each value will be written to
236 the config file. This makes it safe, for example, to add
237 additional fetch refspecs to the origin remote.
SZEDER Gábor7eae4a32018-11-14 11:46:20 +0100238+
239Due to limitations of the current implementation, some configuration
240variables do not take effect until after the initial fetch and checkout.
241Configuration variables known to not take effect are:
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000242++remote.++__<name>__++.mirror++ and ++remote.++__<name>__++.tagOpt++. Use the
SZEDER Gábor7eae4a32018-11-14 11:46:20 +0100243corresponding `--mirror` and `--no-tags` options instead.
Jeff King84054f72011-06-09 16:56:19 -0400244
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000245`--depth` _<depth>_::
Junio C Hamanof4bf2182007-01-01 15:08:06 -0800246 Create a 'shallow' clone with a history truncated to the
Sebastian Schuberthfc142812016-01-08 10:18:21 +0100247 specified number of commits. Implies `--single-branch` unless
Sebastian Schuberth28a1b562016-01-06 14:06:47 +0100248 `--no-single-branch` is given to fetch the histories near the
Junio C Hamano18a74a02016-06-19 13:51:56 -0700249 tips of all branches. If you want to clone submodules shallowly,
250 also pass `--shallow-submodules`.
Junio C Hamanof4bf2182007-01-01 15:08:06 -0800251
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000252++--shallow-since=++__<date>__::
Nguyễn Thái Ngọc Duy994c2aa2016-06-12 17:54:00 +0700253 Create a shallow clone with a history after the specified time.
254
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000255++--shallow-exclude=++__<revision>__::
Nguyễn Thái Ngọc Duy859e5df2016-06-12 17:54:05 +0700256 Create a shallow clone with a history, excluding commits
257 reachable from a specified remote branch or tag. This option
258 can be specified multiple times.
259
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000260`--`[`no-`]`single-branch`::
Nguyễn Thái Ngọc Duy3e6e0ed2012-01-07 21:45:59 +0700261 Clone only the history leading to the tip of a single branch,
262 either specified by the `--branch` option or the primary
Sebastian Schuberth28a1b562016-01-06 14:06:47 +0100263 branch remote's `HEAD` points at.
Ralf Thielow31b808a2012-09-20 20:04:08 +0200264 Further fetches into the resulting repository will only update the
Matthieu Moya6d3bde2012-10-23 13:34:05 +0200265 remote-tracking branch for the branch this option was used for the
Jean-Noël Avilad3717e12024-03-10 19:10:29 +0000266 initial cloning. If the `HEAD` at the remote did not point at any
Matthieu Moya6d3bde2012-10-23 13:34:05 +0200267 branch when `--single-branch` clone was made, no remote-tracking
Ralf Thielow31b808a2012-09-20 20:04:08 +0200268 branch is created.
Nguyễn Thái Ngọc Duy3e6e0ed2012-01-07 21:45:59 +0700269
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000270`--no-tags`::
Ævar Arnfjörð Bjarmason0dab2462017-04-26 23:12:33 +0000271 Don't clone any tags, and set
272 `remote.<remote>.tagOpt=--no-tags` in the config, ensuring
273 that future `git pull` and `git fetch` operations won't follow
274 any tags. Subsequent explicit tag fetches will still work,
275 (see linkgit:git-fetch[1]).
276+
277Can be used in conjunction with `--single-branch` to clone and
278maintain a branch with no references other than a single cloned
279branch. This is useful e.g. to maintain minimal clones of the default
280branch of some repository for search indexing.
281
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000282`--recurse-submodules`[`=`{empty}__<pathspec>__]::
Brandon Williamsbb62e0a2017-03-17 15:38:03 -0700283 After the clone is created, initialize and clone submodules
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000284 within based on the provided _<pathspec>_. If no _=<pathspec>_ is
Brandon Williamsbb62e0a2017-03-17 15:38:03 -0700285 provided, all submodules are initialized and cloned.
Stefan Bellerbc29b0b2017-12-04 18:53:32 -0800286 This option can be given multiple times for pathspecs consisting
287 of multiple entries. The resulting clone has `submodule.active` set to
Brandon Williamsbb62e0a2017-03-17 15:38:03 -0700288 the provided pathspec, or "." (meaning all submodules) if no
Stefan Bellerbc29b0b2017-12-04 18:53:32 -0800289 pathspec is provided.
290+
291Submodules are initialized and cloned using their default settings. This is
292equivalent to running
293`git submodule update --init --recursive <pathspec>` immediately after
294the clone is finished. This option is ignored if the cloned repository does
295not have a worktree/checkout (i.e. if any of `--no-checkout`/`-n`, `--bare`,
296or `--mirror` is given)
Johan Herlande7fed182009-08-20 01:07:43 +0200297
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000298`--`[`no-`]`shallow-submodules`::
Stefan Bellerd22eb042016-04-25 18:12:27 -0700299 All submodules which are cloned will be shallow with a depth of 1.
300
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000301`--`[`no-`]`remote-submodules`::
Jean-Noël Avilafd5041e2019-12-12 21:46:54 +0100302 All submodules which are cloned will use the status of the submodule's
Ben Avison4c691012019-05-19 15:26:49 +0100303 remote-tracking branch to update the submodule, rather than the
Jean-Noël Avilafd5041e2019-12-12 21:46:54 +0100304 superproject's recorded SHA-1. Equivalent to passing `--remote` to
Ben Avison4c691012019-05-19 15:26:49 +0100305 `git submodule update`.
306
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000307`--separate-git-dir=`{empty}__<git-dir>__::
Nguyễn Thái Ngọc Duyb57fb802011-03-19 22:16:56 +0700308 Instead of placing the cloned repository where it is supposed
309 to be, place the cloned repository at the specified directory,
Øystein Walle5fe8f492014-02-05 23:19:43 +0100310 then make a filesystem-agnostic Git symbolic link to there.
Thomas Ackermann2de9b712013-01-21 20:17:53 +0100311 The result is Git repository can be separated from working
Nguyễn Thái Ngọc Duyb57fb802011-03-19 22:16:56 +0700312 tree.
313
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000314`--ref-format=`{empty}__<ref-format>__::
Patrick Steinhardt5ed860f2023-12-29 08:27:09 +0100315
316Specify the given ref storage format for the repository. The valid values are:
317+
318include::ref-storage-format.txt[]
319
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000320`-j` _<n>_::
321`--jobs` _<n>_::
Stefan Beller72290d62016-02-29 18:07:20 -0800322 The number of submodules fetched at the same time.
323 Defaults to the `submodule.fetchJobs` option.
Nguyễn Thái Ngọc Duyb57fb802011-03-19 22:16:56 +0700324
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000325_<repository>_::
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000326 The (possibly remote) _<repository>_ to clone from. See the
Todd Zullinger73364e42018-04-19 13:32:30 -0400327 <<URLS,GIT URLS>> section below for more information on specifying
Andrew Ruder37ba0562007-07-04 17:21:36 -0500328 repositories.
Junio C Hamano6ec311d2005-07-13 20:25:54 -0700329
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000330_<directory>_::
Uwe Zeisbergerfb6a9f92006-06-08 08:50:09 +0200331 The name of a new directory to clone into. The "humanish"
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000332 part of the source repository is used if no _<directory>_ is
Björn Gustavsson550c66f2009-10-20 22:38:38 +0200333 explicitly given (`repo` for `/path/to/repo.git` and `foo`
334 for `host.xz:foo/.git`). Cloning into an existing directory
Alexander Potashevec00d6e2009-05-07 16:04:08 +0400335 is only allowed if the directory is empty.
Junio C Hamano46071662005-11-05 22:26:52 -0800336
Jean-Noël Avila76880f02024-03-29 11:19:40 +0000337`--bundle-uri=`{empty}__<uri>__::
Derrick Stolee55568912022-08-09 13:11:41 +0000338 Before fetching from the remote, fetch a bundle from the given
Jean-Noël Avila45d5ed32024-03-10 19:10:30 +0000339 _<uri>_ and unbundle the data into the local repository. The refs
Derrick Stolee55568912022-08-09 13:11:41 +0000340 in the bundle will be stored under the hidden `refs/bundle/*`
Derrick Stoleee21e6632022-08-09 13:11:43 +0000341 namespace. This option is incompatible with `--depth`,
342 `--shallow-since`, and `--shallow-exclude`.
Derrick Stolee55568912022-08-09 13:11:41 +0000343
Sergei Organov347989f2007-11-16 21:43:16 +0300344:git-clone: 1
Andrew Ruder37ba0562007-07-04 17:21:36 -0500345include::urls.txt[]
346
Nguyễn Thái Ngọc Duy76a87882018-04-30 17:35:33 +0200347EXAMPLES
sean2b5f3ed2006-05-05 15:05:10 -0400348--------
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800349
Michael J Gruber47638682010-03-21 18:30:19 +0100350* Clone from upstream:
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800351+
352------------
W. Trevor King283efb02013-06-22 10:46:27 -0400353$ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux
354$ cd my-linux
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800355$ make
356------------
357
358
Michael J Gruber47638682010-03-21 18:30:19 +0100359* Make a local clone that borrows from the current directory, without checking things out:
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800360+
361------------
362$ git clone -l -s -n . ../copy
Steffen Prohaskaa6e37682007-05-12 13:32:34 +0200363$ cd ../copy
Junio C Hamano1e2ccd32005-12-12 23:24:06 -0800364$ git show-branch
365------------
366
Junio C Hamano8a1a1202006-01-14 16:00:32 -0800367
Michael J Gruber47638682010-03-21 18:30:19 +0100368* Clone from upstream while borrowing from an existing local directory:
Shawn Pearce23edecb2006-04-18 20:19:48 -0400369+
370------------
W. Trevor Kingf22a6542013-06-22 10:46:25 -0400371$ git clone --reference /git/linux.git \
372 git://git.kernel.org/pub/scm/.../linux.git \
373 my-linux
374$ cd my-linux
Shawn Pearce23edecb2006-04-18 20:19:48 -0400375------------
376
377
Michael J Gruber47638682010-03-21 18:30:19 +0100378* Create a bare repository to publish your changes to the public:
Junio C Hamano8a1a1202006-01-14 16:00:32 -0800379+
380------------
Junio C Hamano87e80c42006-01-22 17:24:22 -0800381$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
Junio C Hamano8a1a1202006-01-14 16:00:32 -0800382------------
383
Ævar Arnfjörð Bjarmason16f6b0d2022-09-07 10:27:04 +0200384CONFIGURATION
385-------------
386
387include::includes/cmd-config-section-all.txt[]
388
Ævar Arnfjörð Bjarmason9274dea2022-09-07 10:27:05 +0200389include::config/init.txt[]
390
Ævar Arnfjörð Bjarmason16f6b0d2022-09-07 10:27:04 +0200391include::config/clone.txt[]
392
Junio C Hamano8a1a1202006-01-14 16:00:32 -0800393
Junio C Hamano6ec311d2005-07-13 20:25:54 -0700394GIT
395---
Christian Couder9e1f0a82008-06-06 09:07:32 +0200396Part of the linkgit:git[1] suite