Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | git-clone(1) |
| 2 | ============ |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 4ec0671 | 2007-06-09 20:39:33 | [diff] [blame] | 6 | git-clone - Clone a repository into a new directory |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 11 | [verse] |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 12 | 'git clone' [--template=<template-directory>] |
Junio C Hamano | af1987f | 2008-08-03 07:58:19 | [diff] [blame] | 13 | [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] |
Junio C Hamano | 2bd8a74 | 2009-12-01 21:16:59 | [diff] [blame] | 14 | [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>] |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 15 | [--dissociate] [--separate-git-dir <git-dir>] |
Junio C Hamano | d517690 | 2017-05-16 04:30:56 | [diff] [blame] | 16 | [--depth <depth>] [--[no-]single-branch] [--no-tags] |
Junio C Hamano | 047135e | 2017-12-19 21:57:54 | [diff] [blame] | 17 | [--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules] |
Junio C Hamano | ddc69f1 | 2021-04-08 21:50:11 | [diff] [blame] | 18 | [--[no-]remote-submodules] [--jobs <n>] [--sparse] [--[no-]reject-shallow] |
Junio C Hamano | 67bf224 | 2020-04-22 21:41:44 | [diff] [blame] | 19 | [--filter=<filter>] [--] <repository> |
Junio C Hamano | 73c6486 | 2019-06-18 03:24:20 | [diff] [blame] | 20 | [<directory>] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 21 | |
| 22 | DESCRIPTION |
| 23 | ----------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 24 | |
Junio C Hamano | 5102d9a | 2006-12-08 07:23:46 | [diff] [blame] | 25 | Clones a repository into a newly created directory, creates |
| 26 | remote-tracking branches for each branch in the cloned repository |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 27 | (visible using `git branch --remotes`), and creates and checks out an |
Junio C Hamano | c0e55e7 | 2009-10-10 00:56:29 | [diff] [blame] | 28 | initial branch that is forked from the cloned repository's |
| 29 | currently active branch. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 30 | |
Junio C Hamano | 5102d9a | 2006-12-08 07:23:46 | [diff] [blame] | 31 | After the clone, a plain `git fetch` without arguments will update |
| 32 | all the remote-tracking branches, and a `git pull` without |
| 33 | arguments will in addition merge the remote master branch into the |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 34 | current master branch, if any (this is untrue when "--single-branch" |
| 35 | is given; see below). |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 36 | |
Junio C Hamano | 5102d9a | 2006-12-08 07:23:46 | [diff] [blame] | 37 | This default configuration is achieved by creating references to |
Junio C Hamano | 4fdccb2 | 2010-02-19 09:58:14 | [diff] [blame] | 38 | the remote branch heads under `refs/remotes/origin` and |
Junio C Hamano | 5102d9a | 2006-12-08 07:23:46 | [diff] [blame] | 39 | by initializing `remote.origin.url` and `remote.origin.fetch` |
| 40 | configuration variables. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 41 | |
Junio C Hamano | b288d9e | 2007-01-02 00:04:15 | [diff] [blame] | 42 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 43 | OPTIONS |
| 44 | ------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 45 | -l:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 46 | --local:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 47 | When the repository to clone from is on a local machine, |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 48 | this flag bypasses the normal "Git aware" transport |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 49 | mechanism and clones the repository by making a copy of |
| 50 | HEAD and everything under objects and refs directories. |
Junio C Hamano | b1d6e88 | 2007-08-11 08:30:16 | [diff] [blame] | 51 | The files under `.git/objects/` directory are hardlinked |
Junio C Hamano | 7f2b3cb | 2012-06-22 22:42:39 | [diff] [blame] | 52 | to save space when possible. |
| 53 | + |
| 54 | If the repository is specified as a local path (e.g., `/path/to/repo`), |
| 55 | this is the default, and --local is essentially a no-op. If the |
| 56 | repository is specified as a URL, then this flag is ignored (and we |
| 57 | never use the local optimizations). Specifying `--no-local` will |
| 58 | override the default when `/path/to/repo` is given, using the regular |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 59 | Git transport instead. |
Junio C Hamano | 7887f9b | 2021-01-25 23:32:33 | [diff] [blame] | 60 | + |
| 61 | *NOTE*: this operation can race with concurrent modification to the |
| 62 | source repository, similar to running `cp -r src dst` while modifying |
| 63 | `src`. |
Junio C Hamano | b1d6e88 | 2007-08-11 08:30:16 | [diff] [blame] | 64 | |
| 65 | --no-hardlinks:: |
Junio C Hamano | 5b3533d | 2014-02-27 23:07:15 | [diff] [blame] | 66 | Force the cloning process from a repository on a local |
| 67 | filesystem to copy the files under the `.git/objects` |
| 68 | directory instead of using hardlinks. This may be desirable |
| 69 | if you are trying to make a back-up of your repository. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 70 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 71 | -s:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 72 | --shared:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 73 | When the repository to clone is on the local machine, |
| 74 | instead of using hard links, automatically setup |
Junio C Hamano | 621e123 | 2009-10-26 05:16:47 | [diff] [blame] | 75 | `.git/objects/info/alternates` to share the objects |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 76 | with the source repository. The resulting repository |
| 77 | starts out without any object of its own. |
Junio C Hamano | efe3c63 | 2008-02-14 00:51:31 | [diff] [blame] | 78 | + |
| 79 | *NOTE*: this is a possibly dangerous operation; do *not* use |
| 80 | it unless you understand what it does. If you clone your |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 81 | repository using this option and then delete branches (or use any |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 82 | other Git command that makes any existing commit unreferenced) in the |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 83 | source repository, some objects may become unreferenced (or dangling). |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 84 | These objects may be removed by normal Git operations (such as `git commit`) |
Junio C Hamano | c562f6d | 2020-09-25 22:50:12 | [diff] [blame] | 85 | which automatically call `git maintenance run --auto`. (See |
| 86 | linkgit:git-maintenance[1].) If these objects are removed and were referenced |
| 87 | by the cloned repository, then the cloned repository will become corrupt. |
Junio C Hamano | b937692 | 2009-08-19 00:09:13 | [diff] [blame] | 88 | + |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 89 | Note that running `git repack` without the `--local` option in a repository |
| 90 | cloned with `--shared` will copy objects from the source repository into a pack |
| 91 | in the cloned repository, removing the disk space savings of `clone --shared`. |
| 92 | It is safe, however, to run `git gc`, which uses the `--local` option by |
Junio C Hamano | b937692 | 2009-08-19 00:09:13 | [diff] [blame] | 93 | default. |
| 94 | + |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 95 | If you want to break the dependency of a repository cloned with `--shared` on |
Junio C Hamano | b937692 | 2009-08-19 00:09:13 | [diff] [blame] | 96 | its source repository, you can simply run `git repack -a` to copy all |
| 97 | objects from the source repository into a pack in the cloned repository. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 98 | |
Junio C Hamano | cd45166 | 2016-09-13 00:54:09 | [diff] [blame] | 99 | --reference[-if-able] <repository>:: |
Junio C Hamano | 35b47ca | 2009-09-03 18:11:54 | [diff] [blame] | 100 | If the reference repository is on the local machine, |
Junio C Hamano | 621e123 | 2009-10-26 05:16:47 | [diff] [blame] | 101 | automatically setup `.git/objects/info/alternates` to |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 102 | obtain objects from the reference repository. Using |
| 103 | an already existing repository as an alternate will |
Junio C Hamano | 250f03e | 2007-09-10 01:33:28 | [diff] [blame] | 104 | require fewer objects to be copied from the repository |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 105 | being cloned, reducing network and local storage costs. |
Junio C Hamano | cd45166 | 2016-09-13 00:54:09 | [diff] [blame] | 106 | When using the `--reference-if-able`, a non existing |
| 107 | directory is skipped with a warning instead of aborting |
| 108 | the clone. |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 109 | + |
Junio C Hamano | c9394b2 | 2015-01-07 22:45:48 | [diff] [blame] | 110 | *NOTE*: see the NOTE for the `--shared` option, and also the |
| 111 | `--dissociate` option. |
| 112 | |
| 113 | --dissociate:: |
| 114 | Borrow the objects from reference repositories specified |
| 115 | with the `--reference` options only to reduce network |
Junio C Hamano | 448d132 | 2015-10-30 21:57:54 | [diff] [blame] | 116 | transfer, and stop borrowing from them after a clone is made |
| 117 | by making necessary local copies of borrowed objects. This |
| 118 | option can also be used when cloning locally from a |
| 119 | repository that already borrows objects from another |
| 120 | repository--the new repository will borrow objects from the |
| 121 | same repository, and this option can be used to stop the |
| 122 | borrowing. |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 123 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 124 | -q:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 125 | --quiet:: |
Junio C Hamano | 6ce6b6c | 2010-01-18 01:25:50 | [diff] [blame] | 126 | Operate quietly. Progress is not reported to the standard |
Junio C Hamano | f85ef63 | 2016-02-17 22:31:06 | [diff] [blame] | 127 | error stream. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 128 | |
Junio C Hamano | 7d06a8a | 2008-10-20 05:42:33 | [diff] [blame] | 129 | -v:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 130 | --verbose:: |
Junio C Hamano | ea90ab3 | 2010-03-15 20:32:55 | [diff] [blame] | 131 | Run verbosely. Does not affect the reporting of progress status |
| 132 | to the standard error stream. |
Junio C Hamano | 6ce6b6c | 2010-01-18 01:25:50 | [diff] [blame] | 133 | |
| 134 | --progress:: |
| 135 | Progress status is reported on the standard error stream |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 136 | by default when it is attached to a terminal, unless `--quiet` |
Junio C Hamano | 6ce6b6c | 2010-01-18 01:25:50 | [diff] [blame] | 137 | is specified. This flag forces progress status even if the |
| 138 | standard error stream is not directed to a terminal. |
Junio C Hamano | 7d06a8a | 2008-10-20 05:42:33 | [diff] [blame] | 139 | |
Junio C Hamano | d1063b1 | 2019-05-08 17:18:07 | [diff] [blame] | 140 | --server-option=<option>:: |
| 141 | Transmit the given string to the server when communicating using |
| 142 | protocol version 2. The given string must not contain a NUL or LF |
| 143 | character. The server's handling of server options, including |
| 144 | unknown ones, is server-specific. |
| 145 | When multiple `--server-option=<option>` are given, they are all |
| 146 | sent to the other side in the order listed on the command line. |
| 147 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 148 | -n:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 149 | --no-checkout:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 150 | No checkout of HEAD is performed after the clone is complete. |
| 151 | |
Junio C Hamano | ddc69f1 | 2021-04-08 21:50:11 | [diff] [blame] | 152 | --[no-]reject-shallow:: |
| 153 | Fail if the source repository is a shallow repository. |
| 154 | The 'clone.rejectShallow' configuration variable can be used to |
| 155 | specify the default. |
| 156 | |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 157 | --bare:: |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 158 | Make a 'bare' Git repository. That is, instead of |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 159 | creating `<directory>` and placing the administrative |
| 160 | files in `<directory>/.git`, make the `<directory>` |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 161 | itself the `$GIT_DIR`. This obviously implies the `--no-checkout` |
Junio C Hamano | 9f292e7 | 2006-11-24 11:37:29 | [diff] [blame] | 162 | because there is nowhere to check out the working tree. |
| 163 | Also the branch heads at the remote are copied directly |
| 164 | to corresponding local branch heads, without mapping |
| 165 | them to `refs/remotes/origin/`. When this option is |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 166 | used, neither remote-tracking branches nor the related |
| 167 | configuration variables are created. |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 168 | |
Junio C Hamano | 2f5a989 | 2019-12-25 21:12:55 | [diff] [blame] | 169 | --sparse:: |
Junio C Hamano | 05fe8d1 | 2022-01-04 00:50:38 | [diff] [blame^] | 170 | Employ a sparse-checkout, with only files in the toplevel |
| 171 | directory initially being present. The |
| 172 | linkgit:git-sparse-checkout[1] command can be used to grow the |
| 173 | working directory as needed. |
Junio C Hamano | 2f5a989 | 2019-12-25 21:12:55 | [diff] [blame] | 174 | |
Junio C Hamano | 67bf224 | 2020-04-22 21:41:44 | [diff] [blame] | 175 | --filter=<filter-spec>:: |
| 176 | Use the partial clone feature and request that the server sends |
| 177 | a subset of reachable objects according to a given object filter. |
| 178 | When using `--filter`, the supplied `<filter-spec>` is used for |
| 179 | the partial clone filter. For example, `--filter=blob:none` will |
| 180 | filter out all blobs (file contents) until needed by Git. Also, |
| 181 | `--filter=blob:limit=<size>` will filter out all blobs of size |
| 182 | at least `<size>`. For more details on filter specifications, see |
| 183 | the `--filter` option in linkgit:git-rev-list[1]. |
| 184 | |
Junio C Hamano | af1987f | 2008-08-03 07:58:19 | [diff] [blame] | 185 | --mirror:: |
Junio C Hamano | 657fd8a | 2010-10-07 00:01:24 | [diff] [blame] | 186 | Set up a mirror of the source repository. This implies `--bare`. |
| 187 | Compared to `--bare`, `--mirror` not only maps local branches of the |
| 188 | source to local branches of the target, it maps all refs (including |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 189 | remote-tracking branches, notes etc.) and sets up a refspec configuration such |
Junio C Hamano | 657fd8a | 2010-10-07 00:01:24 | [diff] [blame] | 190 | that all these refs are overwritten by a `git remote update` in the |
| 191 | target repository. |
Junio C Hamano | af1987f | 2008-08-03 07:58:19 | [diff] [blame] | 192 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 193 | -o <name>:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 194 | --origin <name>:: |
Junio C Hamano | 6a3d665 | 2020-10-27 23:01:14 | [diff] [blame] | 195 | Instead of using the remote name `origin` to keep track of the upstream |
| 196 | repository, use `<name>`. Overrides `clone.defaultRemoteName` from the |
| 197 | config. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 198 | |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 199 | -b <name>:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 200 | --branch <name>:: |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 201 | Instead of pointing the newly created HEAD to the branch pointed |
Junio C Hamano | 621e123 | 2009-10-26 05:16:47 | [diff] [blame] | 202 | to by the cloned repository's HEAD, point to `<name>` branch |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 203 | instead. In a non-bare repository, this is the branch that will |
| 204 | be checked out. |
| 205 | `--branch` can also take tags and detaches the HEAD at that commit |
| 206 | in the resulting repository. |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 207 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 208 | -u <upload-pack>:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 209 | --upload-pack <upload-pack>:: |
Junio C Hamano | 3db8b41 | 2008-07-26 06:45:59 | [diff] [blame] | 210 | When given, and the repository to clone from is accessed |
| 211 | via ssh, this specifies a non-default path for the command |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 212 | run on the other end. |
| 213 | |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 214 | --template=<template-directory>:: |
Junio C Hamano | f31d9f5 | 2006-05-28 20:58:09 | [diff] [blame] | 215 | Specify the directory from which templates will be used; |
Junio C Hamano | caa712a | 2010-03-11 01:17:35 | [diff] [blame] | 216 | (See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].) |
Junio C Hamano | f31d9f5 | 2006-05-28 20:58:09 | [diff] [blame] | 217 | |
Junio C Hamano | 708376e | 2011-07-19 20:02:13 | [diff] [blame] | 218 | -c <key>=<value>:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 219 | --config <key>=<value>:: |
Junio C Hamano | 708376e | 2011-07-19 20:02:13 | [diff] [blame] | 220 | Set a configuration variable in the newly-created repository; |
| 221 | this takes effect immediately after the repository is |
| 222 | initialized, but before the remote history is fetched or any |
| 223 | files checked out. The key is in the same format as expected by |
| 224 | linkgit:git-config[1] (e.g., `core.eol=true`). If multiple |
| 225 | values are given for the same key, each value will be written to |
| 226 | the config file. This makes it safe, for example, to add |
| 227 | additional fetch refspecs to the origin remote. |
Junio C Hamano | de48f45 | 2019-01-04 22:31:57 | [diff] [blame] | 228 | + |
| 229 | Due to limitations of the current implementation, some configuration |
| 230 | variables do not take effect until after the initial fetch and checkout. |
| 231 | Configuration variables known to not take effect are: |
| 232 | `remote.<name>.mirror` and `remote.<name>.tagOpt`. Use the |
| 233 | corresponding `--mirror` and `--no-tags` options instead. |
Junio C Hamano | 708376e | 2011-07-19 20:02:13 | [diff] [blame] | 234 | |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 235 | --depth <depth>:: |
Junio C Hamano | b288d9e | 2007-01-02 00:04:15 | [diff] [blame] | 236 | Create a 'shallow' clone with a history truncated to the |
Junio C Hamano | 4e6ba27 | 2016-01-20 23:23:19 | [diff] [blame] | 237 | specified number of commits. Implies `--single-branch` unless |
| 238 | `--no-single-branch` is given to fetch the histories near the |
Junio C Hamano | c6c919b | 2016-07-06 21:34:15 | [diff] [blame] | 239 | tips of all branches. If you want to clone submodules shallowly, |
| 240 | also pass `--shallow-submodules`. |
Junio C Hamano | b288d9e | 2007-01-02 00:04:15 | [diff] [blame] | 241 | |
Junio C Hamano | 20829a4 | 2016-10-10 23:24:44 | [diff] [blame] | 242 | --shallow-since=<date>:: |
| 243 | Create a shallow clone with a history after the specified time. |
| 244 | |
| 245 | --shallow-exclude=<revision>:: |
| 246 | Create a shallow clone with a history, excluding commits |
| 247 | reachable from a specified remote branch or tag. This option |
| 248 | can be specified multiple times. |
| 249 | |
Junio C Hamano | 3d1b5a1 | 2013-05-17 23:34:02 | [diff] [blame] | 250 | --[no-]single-branch:: |
Junio C Hamano | b5be052 | 2012-01-29 22:20:19 | [diff] [blame] | 251 | Clone only the history leading to the tip of a single branch, |
| 252 | either specified by the `--branch` option or the primary |
Junio C Hamano | 4e6ba27 | 2016-01-20 23:23:19 | [diff] [blame] | 253 | branch remote's `HEAD` points at. |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 254 | Further fetches into the resulting repository will only update the |
Junio C Hamano | a129545 | 2012-11-13 22:32:04 | [diff] [blame] | 255 | remote-tracking branch for the branch this option was used for the |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 256 | initial cloning. If the HEAD at the remote did not point at any |
Junio C Hamano | a129545 | 2012-11-13 22:32:04 | [diff] [blame] | 257 | branch when `--single-branch` clone was made, no remote-tracking |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 258 | branch is created. |
Junio C Hamano | b5be052 | 2012-01-29 22:20:19 | [diff] [blame] | 259 | |
Junio C Hamano | d517690 | 2017-05-16 04:30:56 | [diff] [blame] | 260 | --no-tags:: |
| 261 | Don't clone any tags, and set |
| 262 | `remote.<remote>.tagOpt=--no-tags` in the config, ensuring |
| 263 | that future `git pull` and `git fetch` operations won't follow |
| 264 | any tags. Subsequent explicit tag fetches will still work, |
| 265 | (see linkgit:git-fetch[1]). |
| 266 | + |
| 267 | Can be used in conjunction with `--single-branch` to clone and |
| 268 | maintain a branch with no references other than a single cloned |
| 269 | branch. This is useful e.g. to maintain minimal clones of the default |
| 270 | branch of some repository for search indexing. |
| 271 | |
Junio C Hamano | a891178 | 2020-07-07 05:35:57 | [diff] [blame] | 272 | --recurse-submodules[=<pathspec>]:: |
Junio C Hamano | dc8d0c3 | 2017-03-30 23:00:21 | [diff] [blame] | 273 | After the clone is created, initialize and clone submodules |
| 274 | within based on the provided pathspec. If no pathspec is |
| 275 | provided, all submodules are initialized and cloned. |
Junio C Hamano | 047135e | 2017-12-19 21:57:54 | [diff] [blame] | 276 | This option can be given multiple times for pathspecs consisting |
| 277 | of multiple entries. The resulting clone has `submodule.active` set to |
Junio C Hamano | dc8d0c3 | 2017-03-30 23:00:21 | [diff] [blame] | 278 | the provided pathspec, or "." (meaning all submodules) if no |
Junio C Hamano | 047135e | 2017-12-19 21:57:54 | [diff] [blame] | 279 | pathspec is provided. |
| 280 | + |
| 281 | Submodules are initialized and cloned using their default settings. This is |
| 282 | equivalent to running |
| 283 | `git submodule update --init --recursive <pathspec>` immediately after |
| 284 | the clone is finished. This option is ignored if the cloned repository does |
| 285 | not have a worktree/checkout (i.e. if any of `--no-checkout`/`-n`, `--bare`, |
| 286 | or `--mirror` is given) |
Junio C Hamano | 0e066b9 | 2009-08-28 01:08:41 | [diff] [blame] | 287 | |
Junio C Hamano | ccdabca | 2016-05-06 22:27:09 | [diff] [blame] | 288 | --[no-]shallow-submodules:: |
| 289 | All submodules which are cloned will be shallow with a depth of 1. |
| 290 | |
Junio C Hamano | 73c6486 | 2019-06-18 03:24:20 | [diff] [blame] | 291 | --[no-]remote-submodules:: |
Junio C Hamano | 2f5a989 | 2019-12-25 21:12:55 | [diff] [blame] | 292 | All submodules which are cloned will use the status of the submodule's |
Junio C Hamano | 73c6486 | 2019-06-18 03:24:20 | [diff] [blame] | 293 | remote-tracking branch to update the submodule, rather than the |
Junio C Hamano | 2f5a989 | 2019-12-25 21:12:55 | [diff] [blame] | 294 | superproject's recorded SHA-1. Equivalent to passing `--remote` to |
Junio C Hamano | 73c6486 | 2019-06-18 03:24:20 | [diff] [blame] | 295 | `git submodule update`. |
| 296 | |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 297 | --separate-git-dir=<git-dir>:: |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 298 | Instead of placing the cloned repository where it is supposed |
| 299 | to be, place the cloned repository at the specified directory, |
Junio C Hamano | 826f5c4 | 2014-02-07 20:33:30 | [diff] [blame] | 300 | then make a filesystem-agnostic Git symbolic link to there. |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 301 | The result is Git repository can be separated from working |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 302 | tree. |
| 303 | |
Junio C Hamano | bec5da4 | 2016-04-06 22:58:21 | [diff] [blame] | 304 | -j <n>:: |
| 305 | --jobs <n>:: |
| 306 | The number of submodules fetched at the same time. |
| 307 | Defaults to the `submodule.fetchJobs` option. |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 308 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 309 | <repository>:: |
Junio C Hamano | 330aae6 | 2007-07-06 17:01:58 | [diff] [blame] | 310 | The (possibly remote) repository to clone from. See the |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 311 | <<URLS,GIT URLS>> section below for more information on specifying |
Junio C Hamano | 330aae6 | 2007-07-06 17:01:58 | [diff] [blame] | 312 | repositories. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 313 | |
| 314 | <directory>:: |
Junio C Hamano | 8db10ef | 2006-06-09 04:31:57 | [diff] [blame] | 315 | The name of a new directory to clone into. The "humanish" |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 316 | part of the source repository is used if no directory is |
Junio C Hamano | 621e123 | 2009-10-26 05:16:47 | [diff] [blame] | 317 | explicitly given (`repo` for `/path/to/repo.git` and `foo` |
| 318 | for `host.xz:foo/.git`). Cloning into an existing directory |
Junio C Hamano | 89bdb3b | 2009-05-10 06:48:14 | [diff] [blame] | 319 | is only allowed if the directory is empty. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 320 | |
Junio C Hamano | 63777e2 | 2007-11-17 20:52:16 | [diff] [blame] | 321 | :git-clone: 1 |
Junio C Hamano | 330aae6 | 2007-07-06 17:01:58 | [diff] [blame] | 322 | include::urls.txt[] |
| 323 | |
Junio C Hamano | b9d9d90 | 2018-05-23 07:07:42 | [diff] [blame] | 324 | EXAMPLES |
Junio C Hamano | 1bb569e | 2006-05-05 23:14:25 | [diff] [blame] | 325 | -------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 326 | |
Junio C Hamano | 9ccf664 | 2010-03-22 01:47:35 | [diff] [blame] | 327 | * Clone from upstream: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 328 | + |
| 329 | ------------ |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 330 | $ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux |
| 331 | $ cd my-linux |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 332 | $ make |
| 333 | ------------ |
| 334 | |
| 335 | |
Junio C Hamano | 9ccf664 | 2010-03-22 01:47:35 | [diff] [blame] | 336 | * Make a local clone that borrows from the current directory, without checking things out: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 337 | + |
| 338 | ------------ |
| 339 | $ git clone -l -s -n . ../copy |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 340 | $ cd ../copy |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 341 | $ git show-branch |
| 342 | ------------ |
| 343 | |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 344 | |
Junio C Hamano | 9ccf664 | 2010-03-22 01:47:35 | [diff] [blame] | 345 | * Clone from upstream while borrowing from an existing local directory: |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 346 | + |
| 347 | ------------ |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 348 | $ git clone --reference /git/linux.git \ |
| 349 | git://git.kernel.org/pub/scm/.../linux.git \ |
| 350 | my-linux |
| 351 | $ cd my-linux |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 352 | ------------ |
| 353 | |
| 354 | |
Junio C Hamano | 9ccf664 | 2010-03-22 01:47:35 | [diff] [blame] | 355 | * Create a bare repository to publish your changes to the public: |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 356 | + |
| 357 | ------------ |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 358 | $ git clone --bare -l /home/proj/.git /pub/scm/proj.git |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 359 | ------------ |
| 360 | |
| 361 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 362 | GIT |
| 363 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 364 | Part of the linkgit:git[1] suite |