Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 1 | git-clone(1) |
| 2 | ============ |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 3 | |
| 4 | NAME |
| 5 | ---- |
william pursell | 29cf5e1 | 2007-06-09 16:44:12 +0100 | [diff] [blame] | 6 | git-clone - Clone a repository into a new directory |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Jonas Fonseca | 353ce81 | 2005-12-31 18:37:15 +0100 | [diff] [blame] | 11 | [verse] |
Jonathan Nieder | b1889c3 | 2008-06-30 01:09:04 -0500 | [diff] [blame] | 12 | 'git clone' [--template=<template_directory>] |
Johannes Schindelin | bc699af | 2008-08-02 21:38:56 +0200 | [diff] [blame] | 13 | [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] |
David Soria Parra | db9bc00 | 2009-11-30 14:27:52 +0100 | [diff] [blame] | 14 | [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>] |
Junio C Hamano | fb1d6da | 2014-10-14 12:38:52 -0700 | [diff] [blame] | 15 | [--dissociate] [--separate-git-dir <git dir>] |
Ævar Arnfjörð Bjarmason | 0dab246 | 2017-04-26 23:12:33 +0000 | [diff] [blame] | 16 | [--depth <depth>] [--[no-]single-branch] [--no-tags] |
Stefan Beller | bc29b0b | 2017-12-04 18:53:32 -0800 | [diff] [blame] | 17 | [--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules] |
Derrick Stolee | d89f09c | 2019-11-21 22:04:35 +0000 | [diff] [blame] | 18 | [--[no-]remote-submodules] [--jobs <n>] [--sparse] [--] <repository> |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 19 | [<directory>] |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 20 | |
| 21 | DESCRIPTION |
| 22 | ----------- |
Junio C Hamano | 4607166 | 2005-11-05 22:26:52 -0800 | [diff] [blame] | 23 | |
J. Bruce Fields | db9819a | 2006-12-08 01:27:21 -0500 | [diff] [blame] | 24 | Clones a repository into a newly created directory, creates |
| 25 | remote-tracking branches for each branch in the cloned repository |
Quentin Nerden | 3711d1c | 2019-07-02 07:37:40 -0700 | [diff] [blame] | 26 | (visible using `git branch --remotes`), and creates and checks out an |
Jonathan Nieder | 33405be | 2009-10-09 18:07:39 -0500 | [diff] [blame] | 27 | initial branch that is forked from the cloned repository's |
| 28 | currently active branch. |
Junio C Hamano | 4607166 | 2005-11-05 22:26:52 -0800 | [diff] [blame] | 29 | |
J. Bruce Fields | db9819a | 2006-12-08 01:27:21 -0500 | [diff] [blame] | 30 | After the clone, a plain `git fetch` without arguments will update |
| 31 | all the remote-tracking branches, and a `git pull` without |
| 32 | arguments will in addition merge the remote master branch into the |
Ralf Thielow | 31b808a | 2012-09-20 20:04:08 +0200 | [diff] [blame] | 33 | current master branch, if any (this is untrue when "--single-branch" |
| 34 | is given; see below). |
Junio C Hamano | 4607166 | 2005-11-05 22:26:52 -0800 | [diff] [blame] | 35 | |
J. Bruce Fields | db9819a | 2006-12-08 01:27:21 -0500 | [diff] [blame] | 36 | This default configuration is achieved by creating references to |
Jeff King | cc1b8d8 | 2010-02-17 20:16:20 -0500 | [diff] [blame] | 37 | the remote branch heads under `refs/remotes/origin` and |
J. Bruce Fields | db9819a | 2006-12-08 01:27:21 -0500 | [diff] [blame] | 38 | by initializing `remote.origin.url` and `remote.origin.fetch` |
| 39 | configuration variables. |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 40 | |
Junio C Hamano | f4bf218 | 2007-01-01 15:08:06 -0800 | [diff] [blame] | 41 | |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 42 | OPTIONS |
| 43 | ------- |
| 44 | -l:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 45 | --local:: |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 46 | When the repository to clone from is on a local machine, |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 47 | this flag bypasses the normal "Git aware" transport |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 48 | mechanism and clones the repository by making a copy of |
| 49 | HEAD and everything under objects and refs directories. |
Junio C Hamano | 3d5c418 | 2007-08-01 23:42:36 -0700 | [diff] [blame] | 50 | The files under `.git/objects/` directory are hardlinked |
Jeff King | 9197a10 | 2012-05-30 07:09:08 -0400 | [diff] [blame] | 51 | to save space when possible. |
| 52 | + |
| 53 | If the repository is specified as a local path (e.g., `/path/to/repo`), |
| 54 | this is the default, and --local is essentially a no-op. If the |
| 55 | repository is specified as a URL, then this flag is ignored (and we |
Jeff King | 189260b | 2012-05-30 07:10:16 -0400 | [diff] [blame] | 56 | never use the local optimizations). Specifying `--no-local` will |
| 57 | override the default when `/path/to/repo` is given, using the regular |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 58 | Git transport instead. |
Junio C Hamano | 3d5c418 | 2007-08-01 23:42:36 -0700 | [diff] [blame] | 59 | |
| 60 | --no-hardlinks:: |
Albert L. Lash, IV | 897e3e4 | 2014-02-08 15:41:36 -0500 | [diff] [blame] | 61 | Force the cloning process from a repository on a local |
| 62 | filesystem to copy the files under the `.git/objects` |
| 63 | directory instead of using hardlinks. This may be desirable |
| 64 | if you are trying to make a back-up of your repository. |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 65 | |
Eric W. Biederman | a2775c2 | 2005-10-02 13:42:57 -0600 | [diff] [blame] | 66 | -s:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 67 | --shared:: |
Eric W. Biederman | a2775c2 | 2005-10-02 13:42:57 -0600 | [diff] [blame] | 68 | When the repository to clone is on the local machine, |
Junio C Hamano | 4607166 | 2005-11-05 22:26:52 -0800 | [diff] [blame] | 69 | instead of using hard links, automatically setup |
Björn Gustavsson | 550c66f | 2009-10-20 22:38:38 +0200 | [diff] [blame] | 70 | `.git/objects/info/alternates` to share the objects |
Junio C Hamano | 4607166 | 2005-11-05 22:26:52 -0800 | [diff] [blame] | 71 | with the source repository. The resulting repository |
| 72 | starts out without any object of its own. |
Miklos Vajna | 8466887 | 2008-02-12 01:12:57 +0100 | [diff] [blame] | 73 | + |
| 74 | *NOTE*: this is a possibly dangerous operation; do *not* use |
| 75 | it unless you understand what it does. If you clone your |
Brandon Casey | 2498a1a | 2008-04-03 13:26:13 -0500 | [diff] [blame] | 76 | repository using this option and then delete branches (or use any |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 77 | other Git command that makes any existing commit unreferenced) in the |
Brandon Casey | 2498a1a | 2008-04-03 13:26:13 -0500 | [diff] [blame] | 78 | source repository, some objects may become unreferenced (or dangling). |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 79 | These objects may be removed by normal Git operations (such as `git commit`) |
Jonathan Nieder | 483bc4f | 2008-06-30 13:56:34 -0500 | [diff] [blame] | 80 | which automatically call `git gc --auto`. (See linkgit:git-gc[1].) |
| 81 | If these objects are removed and were referenced by the cloned repository, |
| 82 | then the cloned repository will become corrupt. |
Jeff King | 13354f5 | 2009-08-17 02:19:17 -0400 | [diff] [blame] | 83 | + |
Quentin Nerden | 3711d1c | 2019-07-02 07:37:40 -0700 | [diff] [blame] | 84 | Note that running `git repack` without the `--local` option in a repository |
| 85 | cloned with `--shared` will copy objects from the source repository into a pack |
| 86 | in the cloned repository, removing the disk space savings of `clone --shared`. |
| 87 | It is safe, however, to run `git gc`, which uses the `--local` option by |
Jeff King | 13354f5 | 2009-08-17 02:19:17 -0400 | [diff] [blame] | 88 | default. |
| 89 | + |
Quentin Nerden | 3711d1c | 2019-07-02 07:37:40 -0700 | [diff] [blame] | 90 | If you want to break the dependency of a repository cloned with `--shared` on |
Jeff King | 13354f5 | 2009-08-17 02:19:17 -0400 | [diff] [blame] | 91 | its source repository, you can simply run `git repack -a` to copy all |
| 92 | objects from the source repository into a pack in the cloned repository. |
Eric W. Biederman | a2775c2 | 2005-10-02 13:42:57 -0600 | [diff] [blame] | 93 | |
Stefan Beller | f7415b4 | 2016-08-15 14:53:26 -0700 | [diff] [blame] | 94 | --reference[-if-able] <repository>:: |
Miklos Vajna | 4059237 | 2009-09-03 13:24:16 +0200 | [diff] [blame] | 95 | If the reference repository is on the local machine, |
Björn Gustavsson | 550c66f | 2009-10-20 22:38:38 +0200 | [diff] [blame] | 96 | automatically setup `.git/objects/info/alternates` to |
Shawn Pearce | 23edecb | 2006-04-18 20:19:48 -0400 | [diff] [blame] | 97 | obtain objects from the reference repository. Using |
| 98 | an already existing repository as an alternate will |
Mike Ralphson | 451e593 | 2007-09-07 17:43:37 +0100 | [diff] [blame] | 99 | require fewer objects to be copied from the repository |
Shawn Pearce | 23edecb | 2006-04-18 20:19:48 -0400 | [diff] [blame] | 100 | being cloned, reducing network and local storage costs. |
Stefan Beller | f7415b4 | 2016-08-15 14:53:26 -0700 | [diff] [blame] | 101 | When using the `--reference-if-able`, a non existing |
| 102 | directory is skipped with a warning instead of aborting |
| 103 | the clone. |
Brandon Casey | 2498a1a | 2008-04-03 13:26:13 -0500 | [diff] [blame] | 104 | + |
Junio C Hamano | fb1d6da | 2014-10-14 12:38:52 -0700 | [diff] [blame] | 105 | *NOTE*: see the NOTE for the `--shared` option, and also the |
| 106 | `--dissociate` option. |
| 107 | |
| 108 | --dissociate:: |
| 109 | Borrow the objects from reference repositories specified |
| 110 | with the `--reference` options only to reduce network |
Alex Riesen | 0181681 | 2015-10-22 18:41:17 +0200 | [diff] [blame] | 111 | transfer, and stop borrowing from them after a clone is made |
| 112 | by making necessary local copies of borrowed objects. This |
| 113 | option can also be used when cloning locally from a |
| 114 | repository that already borrows objects from another |
| 115 | repository--the new repository will borrow objects from the |
| 116 | same repository, and this option can be used to stop the |
| 117 | borrowing. |
Shawn Pearce | 23edecb | 2006-04-18 20:19:48 -0400 | [diff] [blame] | 118 | |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 119 | -q:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 120 | --quiet:: |
Tay Ray Chuan | 488c316 | 2009-12-26 01:12:04 +0800 | [diff] [blame] | 121 | Operate quietly. Progress is not reported to the standard |
Jeff King | 0d0bac6 | 2016-01-30 02:21:26 -0500 | [diff] [blame] | 122 | error stream. |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 123 | |
Miklos Vajna | 21188b1 | 2008-10-09 01:40:32 +0200 | [diff] [blame] | 124 | -v:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 125 | --verbose:: |
Tay Ray Chuan | c54b74a | 2010-02-24 20:50:20 +0800 | [diff] [blame] | 126 | Run verbosely. Does not affect the reporting of progress status |
| 127 | to the standard error stream. |
Tay Ray Chuan | 5a518ad | 2009-12-26 01:12:06 +0800 | [diff] [blame] | 128 | |
| 129 | --progress:: |
Tay Ray Chuan | 488c316 | 2009-12-26 01:12:04 +0800 | [diff] [blame] | 130 | Progress status is reported on the standard error stream |
Quentin Nerden | 3711d1c | 2019-07-02 07:37:40 -0700 | [diff] [blame] | 131 | by default when it is attached to a terminal, unless `--quiet` |
Tay Ray Chuan | 488c316 | 2009-12-26 01:12:04 +0800 | [diff] [blame] | 132 | is specified. This flag forces progress status even if the |
| 133 | standard error stream is not directed to a terminal. |
Miklos Vajna | 21188b1 | 2008-10-09 01:40:32 +0200 | [diff] [blame] | 134 | |
Jonathan Tan | 6e98305 | 2019-04-12 12:51:22 -0700 | [diff] [blame] | 135 | --server-option=<option>:: |
| 136 | Transmit the given string to the server when communicating using |
| 137 | protocol version 2. The given string must not contain a NUL or LF |
| 138 | character. The server's handling of server options, including |
| 139 | unknown ones, is server-specific. |
| 140 | When multiple `--server-option=<option>` are given, they are all |
| 141 | sent to the other side in the order listed on the command line. |
| 142 | |
Eric W. Biederman | a2775c2 | 2005-10-02 13:42:57 -0600 | [diff] [blame] | 143 | -n:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 144 | --no-checkout:: |
Eric W. Biederman | a2775c2 | 2005-10-02 13:42:57 -0600 | [diff] [blame] | 145 | No checkout of HEAD is performed after the clone is complete. |
| 146 | |
Junio C Hamano | 87e80c4 | 2006-01-22 17:24:22 -0800 | [diff] [blame] | 147 | --bare:: |
Thomas Ackermann | 48a8c26 | 2013-01-21 20:16:20 +0100 | [diff] [blame] | 148 | Make a 'bare' Git repository. That is, instead of |
Junio C Hamano | 8a1a120 | 2006-01-14 16:00:32 -0800 | [diff] [blame] | 149 | creating `<directory>` and placing the administrative |
| 150 | files in `<directory>/.git`, make the `<directory>` |
Quentin Nerden | 3711d1c | 2019-07-02 07:37:40 -0700 | [diff] [blame] | 151 | itself the `$GIT_DIR`. This obviously implies the `--no-checkout` |
Petr Baudis | 7182135 | 2006-11-23 23:58:35 +0100 | [diff] [blame] | 152 | because there is nowhere to check out the working tree. |
| 153 | Also the branch heads at the remote are copied directly |
| 154 | to corresponding local branch heads, without mapping |
| 155 | them to `refs/remotes/origin/`. When this option is |
J. Bruce Fields | 36566cc | 2006-12-31 18:47:34 -0500 | [diff] [blame] | 156 | used, neither remote-tracking branches nor the related |
| 157 | configuration variables are created. |
Junio C Hamano | 8a1a120 | 2006-01-14 16:00:32 -0800 | [diff] [blame] | 158 | |
Derrick Stolee | d89f09c | 2019-11-21 22:04:35 +0000 | [diff] [blame] | 159 | --sparse:: |
| 160 | Initialize the sparse-checkout file so the working |
| 161 | directory starts with only the files in the root |
| 162 | of the repository. The sparse-checkout file can be |
| 163 | modified to grow the working directory as needed. |
| 164 | |
Johannes Schindelin | bc699af | 2008-08-02 21:38:56 +0200 | [diff] [blame] | 165 | --mirror:: |
Uwe Kleine-König | 6db2103 | 2010-10-04 19:28:27 +0200 | [diff] [blame] | 166 | Set up a mirror of the source repository. This implies `--bare`. |
| 167 | Compared to `--bare`, `--mirror` not only maps local branches of the |
| 168 | source to local branches of the target, it maps all refs (including |
Matthieu Moy | 29b9a66 | 2010-11-02 16:31:24 +0100 | [diff] [blame] | 169 | remote-tracking branches, notes etc.) and sets up a refspec configuration such |
Uwe Kleine-König | 6db2103 | 2010-10-04 19:28:27 +0200 | [diff] [blame] | 170 | that all these refs are overwritten by a `git remote update` in the |
| 171 | target repository. |
Johannes Schindelin | bc699af | 2008-08-02 21:38:56 +0200 | [diff] [blame] | 172 | |
Johannes Schindelin | e6c310f | 2005-12-22 23:37:24 +0100 | [diff] [blame] | 173 | -o <name>:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 174 | --origin <name>:: |
Björn Gustavsson | 550c66f | 2009-10-20 22:38:38 +0200 | [diff] [blame] | 175 | Instead of using the remote name `origin` to keep track |
| 176 | of the upstream repository, use `<name>`. |
Johannes Schindelin | e6c310f | 2005-12-22 23:37:24 +0100 | [diff] [blame] | 177 | |
Jeff King | 7a4ee28 | 2009-08-26 15:05:08 -0400 | [diff] [blame] | 178 | -b <name>:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 179 | --branch <name>:: |
Jeff King | 7a4ee28 | 2009-08-26 15:05:08 -0400 | [diff] [blame] | 180 | Instead of pointing the newly created HEAD to the branch pointed |
Björn Gustavsson | 550c66f | 2009-10-20 22:38:38 +0200 | [diff] [blame] | 181 | to by the cloned repository's HEAD, point to `<name>` branch |
Ralf Thielow | 31b808a | 2012-09-20 20:04:08 +0200 | [diff] [blame] | 182 | instead. In a non-bare repository, this is the branch that will |
| 183 | be checked out. |
| 184 | `--branch` can also take tags and detaches the HEAD at that commit |
| 185 | in the resulting repository. |
Jeff King | 7a4ee28 | 2009-08-26 15:05:08 -0400 | [diff] [blame] | 186 | |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 187 | -u <upload-pack>:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 188 | --upload-pack <upload-pack>:: |
Steve Haslam | d3296e3 | 2008-07-25 19:37:48 +0100 | [diff] [blame] | 189 | When given, and the repository to clone from is accessed |
| 190 | via ssh, this specifies a non-default path for the command |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 191 | run on the other end. |
| 192 | |
Junio C Hamano | a57c8ba | 2006-05-28 10:14:38 -0700 | [diff] [blame] | 193 | --template=<template_directory>:: |
| 194 | Specify the directory from which templates will be used; |
Steven Drake | d8a8488 | 2010-02-17 12:44:46 +1300 | [diff] [blame] | 195 | (See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].) |
Junio C Hamano | a57c8ba | 2006-05-28 10:14:38 -0700 | [diff] [blame] | 196 | |
Jeff King | 84054f7 | 2011-06-09 16:56:19 -0400 | [diff] [blame] | 197 | -c <key>=<value>:: |
Quentin Nerden | bfc8c84 | 2019-07-02 07:37:41 -0700 | [diff] [blame] | 198 | --config <key>=<value>:: |
Jeff King | 84054f7 | 2011-06-09 16:56:19 -0400 | [diff] [blame] | 199 | Set a configuration variable in the newly-created repository; |
| 200 | this takes effect immediately after the repository is |
| 201 | initialized, but before the remote history is fetched or any |
| 202 | files checked out. The key is in the same format as expected by |
| 203 | linkgit:git-config[1] (e.g., `core.eol=true`). If multiple |
| 204 | values are given for the same key, each value will be written to |
| 205 | the config file. This makes it safe, for example, to add |
| 206 | additional fetch refspecs to the origin remote. |
SZEDER Gábor | 7eae4a3 | 2018-11-14 11:46:20 +0100 | [diff] [blame] | 207 | + |
| 208 | Due to limitations of the current implementation, some configuration |
| 209 | variables do not take effect until after the initial fetch and checkout. |
| 210 | Configuration variables known to not take effect are: |
| 211 | `remote.<name>.mirror` and `remote.<name>.tagOpt`. Use the |
| 212 | corresponding `--mirror` and `--no-tags` options instead. |
Jeff King | 84054f7 | 2011-06-09 16:56:19 -0400 | [diff] [blame] | 213 | |
Christian Schlotter | f496454 | 2007-02-19 13:35:35 +0100 | [diff] [blame] | 214 | --depth <depth>:: |
Junio C Hamano | f4bf218 | 2007-01-01 15:08:06 -0800 | [diff] [blame] | 215 | Create a 'shallow' clone with a history truncated to the |
Sebastian Schuberth | fc14281 | 2016-01-08 10:18:21 +0100 | [diff] [blame] | 216 | specified number of commits. Implies `--single-branch` unless |
Sebastian Schuberth | 28a1b56 | 2016-01-06 14:06:47 +0100 | [diff] [blame] | 217 | `--no-single-branch` is given to fetch the histories near the |
Junio C Hamano | 18a74a0 | 2016-06-19 13:51:56 -0700 | [diff] [blame] | 218 | tips of all branches. If you want to clone submodules shallowly, |
| 219 | also pass `--shallow-submodules`. |
Junio C Hamano | f4bf218 | 2007-01-01 15:08:06 -0800 | [diff] [blame] | 220 | |
Nguyễn Thái Ngọc Duy | 994c2aa | 2016-06-12 17:54:00 +0700 | [diff] [blame] | 221 | --shallow-since=<date>:: |
| 222 | Create a shallow clone with a history after the specified time. |
| 223 | |
Nguyễn Thái Ngọc Duy | 859e5df | 2016-06-12 17:54:05 +0700 | [diff] [blame] | 224 | --shallow-exclude=<revision>:: |
| 225 | Create a shallow clone with a history, excluding commits |
| 226 | reachable from a specified remote branch or tag. This option |
| 227 | can be specified multiple times. |
| 228 | |
Felipe Contreras | 0460ed2 | 2013-05-08 20:16:55 -0500 | [diff] [blame] | 229 | --[no-]single-branch:: |
Nguyễn Thái Ngọc Duy | 3e6e0ed | 2012-01-07 21:45:59 +0700 | [diff] [blame] | 230 | Clone only the history leading to the tip of a single branch, |
| 231 | either specified by the `--branch` option or the primary |
Sebastian Schuberth | 28a1b56 | 2016-01-06 14:06:47 +0100 | [diff] [blame] | 232 | branch remote's `HEAD` points at. |
Ralf Thielow | 31b808a | 2012-09-20 20:04:08 +0200 | [diff] [blame] | 233 | Further fetches into the resulting repository will only update the |
Matthieu Moy | a6d3bde | 2012-10-23 13:34:05 +0200 | [diff] [blame] | 234 | remote-tracking branch for the branch this option was used for the |
Ralf Thielow | 31b808a | 2012-09-20 20:04:08 +0200 | [diff] [blame] | 235 | initial cloning. If the HEAD at the remote did not point at any |
Matthieu Moy | a6d3bde | 2012-10-23 13:34:05 +0200 | [diff] [blame] | 236 | branch when `--single-branch` clone was made, no remote-tracking |
Ralf Thielow | 31b808a | 2012-09-20 20:04:08 +0200 | [diff] [blame] | 237 | branch is created. |
Nguyễn Thái Ngọc Duy | 3e6e0ed | 2012-01-07 21:45:59 +0700 | [diff] [blame] | 238 | |
Ævar Arnfjörð Bjarmason | 0dab246 | 2017-04-26 23:12:33 +0000 | [diff] [blame] | 239 | --no-tags:: |
| 240 | Don't clone any tags, and set |
| 241 | `remote.<remote>.tagOpt=--no-tags` in the config, ensuring |
| 242 | that future `git pull` and `git fetch` operations won't follow |
| 243 | any tags. Subsequent explicit tag fetches will still work, |
| 244 | (see linkgit:git-fetch[1]). |
| 245 | + |
| 246 | Can be used in conjunction with `--single-branch` to clone and |
| 247 | maintain a branch with no references other than a single cloned |
| 248 | branch. This is useful e.g. to maintain minimal clones of the default |
| 249 | branch of some repository for search indexing. |
| 250 | |
Brandon Williams | bb62e0a | 2017-03-17 15:38:03 -0700 | [diff] [blame] | 251 | --recurse-submodules[=<pathspec]:: |
| 252 | After the clone is created, initialize and clone submodules |
| 253 | within based on the provided pathspec. If no pathspec is |
| 254 | provided, all submodules are initialized and cloned. |
Stefan Beller | bc29b0b | 2017-12-04 18:53:32 -0800 | [diff] [blame] | 255 | This option can be given multiple times for pathspecs consisting |
| 256 | of multiple entries. The resulting clone has `submodule.active` set to |
Brandon Williams | bb62e0a | 2017-03-17 15:38:03 -0700 | [diff] [blame] | 257 | the provided pathspec, or "." (meaning all submodules) if no |
Stefan Beller | bc29b0b | 2017-12-04 18:53:32 -0800 | [diff] [blame] | 258 | pathspec is provided. |
| 259 | + |
| 260 | Submodules are initialized and cloned using their default settings. This is |
| 261 | equivalent to running |
| 262 | `git submodule update --init --recursive <pathspec>` immediately after |
| 263 | the clone is finished. This option is ignored if the cloned repository does |
| 264 | not have a worktree/checkout (i.e. if any of `--no-checkout`/`-n`, `--bare`, |
| 265 | or `--mirror` is given) |
Johan Herland | e7fed18 | 2009-08-20 01:07:43 +0200 | [diff] [blame] | 266 | |
Stefan Beller | d22eb04 | 2016-04-25 18:12:27 -0700 | [diff] [blame] | 267 | --[no-]shallow-submodules:: |
| 268 | All submodules which are cloned will be shallow with a depth of 1. |
| 269 | |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 270 | --[no-]remote-submodules:: |
Jean-Noël Avila | fd5041e | 2019-12-12 21:46:54 +0100 | [diff] [blame] | 271 | All submodules which are cloned will use the status of the submodule's |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 272 | remote-tracking branch to update the submodule, rather than the |
Jean-Noël Avila | fd5041e | 2019-12-12 21:46:54 +0100 | [diff] [blame] | 273 | superproject's recorded SHA-1. Equivalent to passing `--remote` to |
Ben Avison | 4c69101 | 2019-05-19 15:26:49 +0100 | [diff] [blame] | 274 | `git submodule update`. |
| 275 | |
Nguyễn Thái Ngọc Duy | b57fb80 | 2011-03-19 22:16:56 +0700 | [diff] [blame] | 276 | --separate-git-dir=<git dir>:: |
| 277 | Instead of placing the cloned repository where it is supposed |
| 278 | to be, place the cloned repository at the specified directory, |
Øystein Walle | 5fe8f49 | 2014-02-05 23:19:43 +0100 | [diff] [blame] | 279 | then make a filesystem-agnostic Git symbolic link to there. |
Thomas Ackermann | 2de9b71 | 2013-01-21 20:17:53 +0100 | [diff] [blame] | 280 | The result is Git repository can be separated from working |
Nguyễn Thái Ngọc Duy | b57fb80 | 2011-03-19 22:16:56 +0700 | [diff] [blame] | 281 | tree. |
| 282 | |
Stefan Beller | 72290d6 | 2016-02-29 18:07:20 -0800 | [diff] [blame] | 283 | -j <n>:: |
| 284 | --jobs <n>:: |
| 285 | The number of submodules fetched at the same time. |
| 286 | Defaults to the `submodule.fetchJobs` option. |
Nguyễn Thái Ngọc Duy | b57fb80 | 2011-03-19 22:16:56 +0700 | [diff] [blame] | 287 | |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 288 | <repository>:: |
Andrew Ruder | 37ba056 | 2007-07-04 17:21:36 -0500 | [diff] [blame] | 289 | The (possibly remote) repository to clone from. See the |
Todd Zullinger | 73364e4 | 2018-04-19 13:32:30 -0400 | [diff] [blame] | 290 | <<URLS,GIT URLS>> section below for more information on specifying |
Andrew Ruder | 37ba056 | 2007-07-04 17:21:36 -0500 | [diff] [blame] | 291 | repositories. |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 292 | |
| 293 | <directory>:: |
Uwe Zeisberger | fb6a9f9 | 2006-06-08 08:50:09 +0200 | [diff] [blame] | 294 | The name of a new directory to clone into. The "humanish" |
Andreas Ericsson | 0879aa2 | 2005-11-10 12:58:08 +0100 | [diff] [blame] | 295 | part of the source repository is used if no directory is |
Björn Gustavsson | 550c66f | 2009-10-20 22:38:38 +0200 | [diff] [blame] | 296 | explicitly given (`repo` for `/path/to/repo.git` and `foo` |
| 297 | for `host.xz:foo/.git`). Cloning into an existing directory |
Alexander Potashev | ec00d6e | 2009-05-07 16:04:08 +0400 | [diff] [blame] | 298 | is only allowed if the directory is empty. |
Junio C Hamano | 4607166 | 2005-11-05 22:26:52 -0800 | [diff] [blame] | 299 | |
Sergei Organov | 347989f | 2007-11-16 21:43:16 +0300 | [diff] [blame] | 300 | :git-clone: 1 |
Andrew Ruder | 37ba056 | 2007-07-04 17:21:36 -0500 | [diff] [blame] | 301 | include::urls.txt[] |
| 302 | |
Nguyễn Thái Ngọc Duy | 76a8788 | 2018-04-30 17:35:33 +0200 | [diff] [blame] | 303 | EXAMPLES |
sean | 2b5f3ed | 2006-05-05 15:05:10 -0400 | [diff] [blame] | 304 | -------- |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 305 | |
Michael J Gruber | 4763868 | 2010-03-21 18:30:19 +0100 | [diff] [blame] | 306 | * Clone from upstream: |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 307 | + |
| 308 | ------------ |
W. Trevor King | 283efb0 | 2013-06-22 10:46:27 -0400 | [diff] [blame] | 309 | $ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux |
| 310 | $ cd my-linux |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 311 | $ make |
| 312 | ------------ |
| 313 | |
| 314 | |
Michael J Gruber | 4763868 | 2010-03-21 18:30:19 +0100 | [diff] [blame] | 315 | * Make a local clone that borrows from the current directory, without checking things out: |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 316 | + |
| 317 | ------------ |
| 318 | $ git clone -l -s -n . ../copy |
Steffen Prohaska | a6e3768 | 2007-05-12 13:32:34 +0200 | [diff] [blame] | 319 | $ cd ../copy |
Junio C Hamano | 1e2ccd3 | 2005-12-12 23:24:06 -0800 | [diff] [blame] | 320 | $ git show-branch |
| 321 | ------------ |
| 322 | |
Junio C Hamano | 8a1a120 | 2006-01-14 16:00:32 -0800 | [diff] [blame] | 323 | |
Michael J Gruber | 4763868 | 2010-03-21 18:30:19 +0100 | [diff] [blame] | 324 | * Clone from upstream while borrowing from an existing local directory: |
Shawn Pearce | 23edecb | 2006-04-18 20:19:48 -0400 | [diff] [blame] | 325 | + |
| 326 | ------------ |
W. Trevor King | f22a654 | 2013-06-22 10:46:25 -0400 | [diff] [blame] | 327 | $ git clone --reference /git/linux.git \ |
| 328 | git://git.kernel.org/pub/scm/.../linux.git \ |
| 329 | my-linux |
| 330 | $ cd my-linux |
Shawn Pearce | 23edecb | 2006-04-18 20:19:48 -0400 | [diff] [blame] | 331 | ------------ |
| 332 | |
| 333 | |
Michael J Gruber | 4763868 | 2010-03-21 18:30:19 +0100 | [diff] [blame] | 334 | * Create a bare repository to publish your changes to the public: |
Junio C Hamano | 8a1a120 | 2006-01-14 16:00:32 -0800 | [diff] [blame] | 335 | + |
| 336 | ------------ |
Junio C Hamano | 87e80c4 | 2006-01-22 17:24:22 -0800 | [diff] [blame] | 337 | $ git clone --bare -l /home/proj/.git /pub/scm/proj.git |
Junio C Hamano | 8a1a120 | 2006-01-14 16:00:32 -0800 | [diff] [blame] | 338 | ------------ |
| 339 | |
| 340 | |
Junio C Hamano | 6ec311d | 2005-07-13 20:25:54 -0700 | [diff] [blame] | 341 | GIT |
| 342 | --- |
Christian Couder | 9e1f0a8 | 2008-06-06 09:07:32 +0200 | [diff] [blame] | 343 | Part of the linkgit:git[1] suite |