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 | 5f907e9 | 2022-02-26 00:21:27 | [diff] [blame] | 19 | [--filter=<filter> [--also-filter-submodules]] [--] <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 | + |
Junio C Hamano | fdb7c3f | 2023-04-20 22:20:22 | [diff] [blame] | 61 | If the repository's `$GIT_DIR/objects` has symbolic links or is a |
| 62 | symbolic link, the clone will fail. This is a security measure to |
| 63 | prevent the unintentional copying of files by dereferencing the symbolic |
| 64 | links. |
| 65 | + |
Junio C Hamano | 7887f9b | 2021-01-25 23:32:33 | [diff] [blame] | 66 | *NOTE*: this operation can race with concurrent modification to the |
| 67 | source repository, similar to running `cp -r src dst` while modifying |
| 68 | `src`. |
Junio C Hamano | b1d6e88 | 2007-08-11 08:30:16 | [diff] [blame] | 69 | |
| 70 | --no-hardlinks:: |
Junio C Hamano | 5b3533d | 2014-02-27 23:07:15 | [diff] [blame] | 71 | 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 Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 75 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 76 | -s:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 77 | --shared:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 78 | When the repository to clone is on the local machine, |
| 79 | instead of using hard links, automatically setup |
Junio C Hamano | 621e123 | 2009-10-26 05:16:47 | [diff] [blame] | 80 | `.git/objects/info/alternates` to share the objects |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 81 | with the source repository. The resulting repository |
| 82 | starts out without any object of its own. |
Junio C Hamano | efe3c63 | 2008-02-14 00:51:31 | [diff] [blame] | 83 | + |
| 84 | *NOTE*: this is a possibly dangerous operation; do *not* use |
| 85 | it unless you understand what it does. If you clone your |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 86 | repository using this option and then delete branches (or use any |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 87 | other Git command that makes any existing commit unreferenced) in the |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 88 | source repository, some objects may become unreferenced (or dangling). |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 89 | 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] | 90 | which automatically call `git maintenance run --auto`. (See |
| 91 | linkgit:git-maintenance[1].) If these objects are removed and were referenced |
| 92 | by the cloned repository, then the cloned repository will become corrupt. |
Junio C Hamano | b937692 | 2009-08-19 00:09:13 | [diff] [blame] | 93 | + |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 94 | Note that running `git repack` without the `--local` option in a repository |
| 95 | cloned with `--shared` will copy objects from the source repository into a pack |
| 96 | in the cloned repository, removing the disk space savings of `clone --shared`. |
| 97 | 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] | 98 | default. |
| 99 | + |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 100 | 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] | 101 | its source repository, you can simply run `git repack -a` to copy all |
| 102 | objects from the source repository into a pack in the cloned repository. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 103 | |
Junio C Hamano | cd45166 | 2016-09-13 00:54:09 | [diff] [blame] | 104 | --reference[-if-able] <repository>:: |
Junio C Hamano | 35b47ca | 2009-09-03 18:11:54 | [diff] [blame] | 105 | If the reference repository is on the local machine, |
Junio C Hamano | 621e123 | 2009-10-26 05:16:47 | [diff] [blame] | 106 | automatically setup `.git/objects/info/alternates` to |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 107 | obtain objects from the reference repository. Using |
| 108 | an already existing repository as an alternate will |
Junio C Hamano | 250f03e | 2007-09-10 01:33:28 | [diff] [blame] | 109 | require fewer objects to be copied from the repository |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 110 | being cloned, reducing network and local storage costs. |
Junio C Hamano | cd45166 | 2016-09-13 00:54:09 | [diff] [blame] | 111 | When using the `--reference-if-able`, a non existing |
| 112 | directory is skipped with a warning instead of aborting |
| 113 | the clone. |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 114 | + |
Junio C Hamano | c9394b2 | 2015-01-07 22:45:48 | [diff] [blame] | 115 | *NOTE*: see the NOTE for the `--shared` option, and also the |
| 116 | `--dissociate` option. |
| 117 | |
| 118 | --dissociate:: |
| 119 | Borrow the objects from reference repositories specified |
| 120 | with the `--reference` options only to reduce network |
Junio C Hamano | 448d132 | 2015-10-30 21:57:54 | [diff] [blame] | 121 | 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. |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 128 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 129 | -q:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 130 | --quiet:: |
Junio C Hamano | 6ce6b6c | 2010-01-18 01:25:50 | [diff] [blame] | 131 | Operate quietly. Progress is not reported to the standard |
Junio C Hamano | f85ef63 | 2016-02-17 22:31:06 | [diff] [blame] | 132 | error stream. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 133 | |
Junio C Hamano | 7d06a8a | 2008-10-20 05:42:33 | [diff] [blame] | 134 | -v:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 135 | --verbose:: |
Junio C Hamano | ea90ab3 | 2010-03-15 20:32:55 | [diff] [blame] | 136 | Run verbosely. Does not affect the reporting of progress status |
| 137 | to the standard error stream. |
Junio C Hamano | 6ce6b6c | 2010-01-18 01:25:50 | [diff] [blame] | 138 | |
| 139 | --progress:: |
| 140 | Progress status is reported on the standard error stream |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 141 | by default when it is attached to a terminal, unless `--quiet` |
Junio C Hamano | 6ce6b6c | 2010-01-18 01:25:50 | [diff] [blame] | 142 | is specified. This flag forces progress status even if the |
| 143 | standard error stream is not directed to a terminal. |
Junio C Hamano | 7d06a8a | 2008-10-20 05:42:33 | [diff] [blame] | 144 | |
Junio C Hamano | d1063b1 | 2019-05-08 17:18:07 | [diff] [blame] | 145 | --server-option=<option>:: |
| 146 | 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. |
| 150 | When multiple `--server-option=<option>` are given, they are all |
| 151 | sent to the other side in the order listed on the command line. |
| 152 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 153 | -n:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 154 | --no-checkout:: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 155 | No checkout of HEAD is performed after the clone is complete. |
| 156 | |
Junio C Hamano | ddc69f1 | 2021-04-08 21:50:11 | [diff] [blame] | 157 | --[no-]reject-shallow:: |
| 158 | Fail if the source repository is a shallow repository. |
| 159 | The 'clone.rejectShallow' configuration variable can be used to |
| 160 | specify the default. |
| 161 | |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 162 | --bare:: |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 163 | Make a 'bare' Git repository. That is, instead of |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 164 | creating `<directory>` and placing the administrative |
| 165 | files in `<directory>/.git`, make the `<directory>` |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 166 | itself the `$GIT_DIR`. This obviously implies the `--no-checkout` |
Junio C Hamano | 9f292e7 | 2006-11-24 11:37:29 | [diff] [blame] | 167 | 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 |
Junio C Hamano | d3361ad | 2007-01-01 03:20:24 | [diff] [blame] | 171 | used, neither remote-tracking branches nor the related |
| 172 | configuration variables are created. |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 173 | |
Junio C Hamano | 2f5a989 | 2019-12-25 21:12:55 | [diff] [blame] | 174 | --sparse:: |
Junio C Hamano | 05fe8d1 | 2022-01-04 00:50:38 | [diff] [blame] | 175 | 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. |
Junio C Hamano | 2f5a989 | 2019-12-25 21:12:55 | [diff] [blame] | 179 | |
Junio C Hamano | 67bf224 | 2020-04-22 21:41:44 | [diff] [blame] | 180 | --filter=<filter-spec>:: |
| 181 | Use the partial clone feature and request that the server sends |
| 182 | a subset of reachable objects according to a given object filter. |
| 183 | When using `--filter`, the supplied `<filter-spec>` is used for |
| 184 | the partial clone filter. For example, `--filter=blob:none` will |
| 185 | filter out all blobs (file contents) until needed by Git. Also, |
| 186 | `--filter=blob:limit=<size>` will filter out all blobs of size |
| 187 | at least `<size>`. For more details on filter specifications, see |
| 188 | the `--filter` option in linkgit:git-rev-list[1]. |
| 189 | |
Junio C Hamano | 5f907e9 | 2022-02-26 00:21:27 | [diff] [blame] | 190 | --also-filter-submodules:: |
| 191 | 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 | |
Junio C Hamano | af1987f | 2008-08-03 07:58:19 | [diff] [blame] | 195 | --mirror:: |
Junio C Hamano | 657fd8a | 2010-10-07 00:01:24 | [diff] [blame] | 196 | 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 |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 199 | remote-tracking branches, notes etc.) and sets up a refspec configuration such |
Junio C Hamano | 657fd8a | 2010-10-07 00:01:24 | [diff] [blame] | 200 | that all these refs are overwritten by a `git remote update` in the |
| 201 | target repository. |
Junio C Hamano | af1987f | 2008-08-03 07:58:19 | [diff] [blame] | 202 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 203 | -o <name>:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 204 | --origin <name>:: |
Junio C Hamano | 6a3d665 | 2020-10-27 23:01:14 | [diff] [blame] | 205 | Instead of using the remote name `origin` to keep track of the upstream |
| 206 | repository, use `<name>`. Overrides `clone.defaultRemoteName` from the |
| 207 | config. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 208 | |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 209 | -b <name>:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 210 | --branch <name>:: |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 211 | Instead of pointing the newly created HEAD to the branch pointed |
Junio C Hamano | 621e123 | 2009-10-26 05:16:47 | [diff] [blame] | 212 | to by the cloned repository's HEAD, point to `<name>` branch |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 213 | 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. |
Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 217 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 218 | -u <upload-pack>:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 219 | --upload-pack <upload-pack>:: |
Junio C Hamano | 3db8b41 | 2008-07-26 06:45:59 | [diff] [blame] | 220 | When given, and the repository to clone from is accessed |
| 221 | via ssh, this specifies a non-default path for the command |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 222 | run on the other end. |
| 223 | |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 224 | --template=<template-directory>:: |
Junio C Hamano | f31d9f5 | 2006-05-28 20:58:09 | [diff] [blame] | 225 | Specify the directory from which templates will be used; |
Junio C Hamano | caa712a | 2010-03-11 01:17:35 | [diff] [blame] | 226 | (See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].) |
Junio C Hamano | f31d9f5 | 2006-05-28 20:58:09 | [diff] [blame] | 227 | |
Junio C Hamano | 708376e | 2011-07-19 20:02:13 | [diff] [blame] | 228 | -c <key>=<value>:: |
Junio C Hamano | 0906e98 | 2019-07-12 20:33:43 | [diff] [blame] | 229 | --config <key>=<value>:: |
Junio C Hamano | 708376e | 2011-07-19 20:02:13 | [diff] [blame] | 230 | 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 |
| 233 | files checked out. The key is in the same format as expected by |
| 234 | 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. |
Junio C Hamano | de48f45 | 2019-01-04 22:31:57 | [diff] [blame] | 238 | + |
| 239 | Due to limitations of the current implementation, some configuration |
| 240 | variables do not take effect until after the initial fetch and checkout. |
| 241 | Configuration variables known to not take effect are: |
| 242 | `remote.<name>.mirror` and `remote.<name>.tagOpt`. Use the |
| 243 | corresponding `--mirror` and `--no-tags` options instead. |
Junio C Hamano | 708376e | 2011-07-19 20:02:13 | [diff] [blame] | 244 | |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 245 | --depth <depth>:: |
Junio C Hamano | b288d9e | 2007-01-02 00:04:15 | [diff] [blame] | 246 | Create a 'shallow' clone with a history truncated to the |
Junio C Hamano | 4e6ba27 | 2016-01-20 23:23:19 | [diff] [blame] | 247 | specified number of commits. Implies `--single-branch` unless |
| 248 | `--no-single-branch` is given to fetch the histories near the |
Junio C Hamano | c6c919b | 2016-07-06 21:34:15 | [diff] [blame] | 249 | tips of all branches. If you want to clone submodules shallowly, |
| 250 | also pass `--shallow-submodules`. |
Junio C Hamano | b288d9e | 2007-01-02 00:04:15 | [diff] [blame] | 251 | |
Junio C Hamano | 20829a4 | 2016-10-10 23:24:44 | [diff] [blame] | 252 | --shallow-since=<date>:: |
| 253 | Create a shallow clone with a history after the specified time. |
| 254 | |
| 255 | --shallow-exclude=<revision>:: |
| 256 | 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 | |
Junio C Hamano | 3d1b5a1 | 2013-05-17 23:34:02 | [diff] [blame] | 260 | --[no-]single-branch:: |
Junio C Hamano | b5be052 | 2012-01-29 22:20:19 | [diff] [blame] | 261 | Clone only the history leading to the tip of a single branch, |
| 262 | either specified by the `--branch` option or the primary |
Junio C Hamano | 4e6ba27 | 2016-01-20 23:23:19 | [diff] [blame] | 263 | branch remote's `HEAD` points at. |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 264 | Further fetches into the resulting repository will only update the |
Junio C Hamano | a129545 | 2012-11-13 22:32:04 | [diff] [blame] | 265 | remote-tracking branch for the branch this option was used for the |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 266 | 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] | 267 | branch when `--single-branch` clone was made, no remote-tracking |
Junio C Hamano | 6a8a848 | 2012-10-01 20:59:41 | [diff] [blame] | 268 | branch is created. |
Junio C Hamano | b5be052 | 2012-01-29 22:20:19 | [diff] [blame] | 269 | |
Junio C Hamano | d517690 | 2017-05-16 04:30:56 | [diff] [blame] | 270 | --no-tags:: |
| 271 | 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 | + |
| 277 | Can be used in conjunction with `--single-branch` to clone and |
| 278 | maintain a branch with no references other than a single cloned |
| 279 | branch. This is useful e.g. to maintain minimal clones of the default |
| 280 | branch of some repository for search indexing. |
| 281 | |
Junio C Hamano | a891178 | 2020-07-07 05:35:57 | [diff] [blame] | 282 | --recurse-submodules[=<pathspec>]:: |
Junio C Hamano | dc8d0c3 | 2017-03-30 23:00:21 | [diff] [blame] | 283 | After the clone is created, initialize and clone submodules |
| 284 | within based on the provided pathspec. If no pathspec is |
| 285 | provided, all submodules are initialized and cloned. |
Junio C Hamano | 047135e | 2017-12-19 21:57:54 | [diff] [blame] | 286 | This option can be given multiple times for pathspecs consisting |
| 287 | of multiple entries. The resulting clone has `submodule.active` set to |
Junio C Hamano | dc8d0c3 | 2017-03-30 23:00:21 | [diff] [blame] | 288 | the provided pathspec, or "." (meaning all submodules) if no |
Junio C Hamano | 047135e | 2017-12-19 21:57:54 | [diff] [blame] | 289 | pathspec is provided. |
| 290 | + |
| 291 | Submodules are initialized and cloned using their default settings. This is |
| 292 | equivalent to running |
| 293 | `git submodule update --init --recursive <pathspec>` immediately after |
| 294 | the clone is finished. This option is ignored if the cloned repository does |
| 295 | not have a worktree/checkout (i.e. if any of `--no-checkout`/`-n`, `--bare`, |
| 296 | or `--mirror` is given) |
Junio C Hamano | 0e066b9 | 2009-08-28 01:08:41 | [diff] [blame] | 297 | |
Junio C Hamano | ccdabca | 2016-05-06 22:27:09 | [diff] [blame] | 298 | --[no-]shallow-submodules:: |
| 299 | All submodules which are cloned will be shallow with a depth of 1. |
| 300 | |
Junio C Hamano | 73c6486 | 2019-06-18 03:24:20 | [diff] [blame] | 301 | --[no-]remote-submodules:: |
Junio C Hamano | 2f5a989 | 2019-12-25 21:12:55 | [diff] [blame] | 302 | 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] | 303 | remote-tracking branch to update the submodule, rather than the |
Junio C Hamano | 2f5a989 | 2019-12-25 21:12:55 | [diff] [blame] | 304 | superproject's recorded SHA-1. Equivalent to passing `--remote` to |
Junio C Hamano | 73c6486 | 2019-06-18 03:24:20 | [diff] [blame] | 305 | `git submodule update`. |
| 306 | |
Junio C Hamano | 59a32b0 | 2021-12-10 22:53:38 | [diff] [blame] | 307 | --separate-git-dir=<git-dir>:: |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 308 | Instead of placing the cloned repository where it is supposed |
| 309 | to be, place the cloned repository at the specified directory, |
Junio C Hamano | 826f5c4 | 2014-02-07 20:33:30 | [diff] [blame] | 310 | then make a filesystem-agnostic Git symbolic link to there. |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 311 | The result is Git repository can be separated from working |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 312 | tree. |
| 313 | |
Junio C Hamano | bec5da4 | 2016-04-06 22:58:21 | [diff] [blame] | 314 | -j <n>:: |
| 315 | --jobs <n>:: |
| 316 | The number of submodules fetched at the same time. |
| 317 | Defaults to the `submodule.fetchJobs` option. |
Junio C Hamano | a03ac86 | 2011-04-02 04:32:29 | [diff] [blame] | 318 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 319 | <repository>:: |
Junio C Hamano | 330aae6 | 2007-07-06 17:01:58 | [diff] [blame] | 320 | The (possibly remote) repository to clone from. See the |
Junio C Hamano | ccb8252 | 2018-05-08 07:52:09 | [diff] [blame] | 321 | <<URLS,GIT URLS>> section below for more information on specifying |
Junio C Hamano | 330aae6 | 2007-07-06 17:01:58 | [diff] [blame] | 322 | repositories. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 323 | |
| 324 | <directory>:: |
Junio C Hamano | 8db10ef | 2006-06-09 04:31:57 | [diff] [blame] | 325 | The name of a new directory to clone into. The "humanish" |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 326 | part of the source repository is used if no directory is |
Junio C Hamano | 621e123 | 2009-10-26 05:16:47 | [diff] [blame] | 327 | explicitly given (`repo` for `/path/to/repo.git` and `foo` |
| 328 | for `host.xz:foo/.git`). Cloning into an existing directory |
Junio C Hamano | 89bdb3b | 2009-05-10 06:48:14 | [diff] [blame] | 329 | is only allowed if the directory is empty. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 330 | |
Junio C Hamano | f7f8f21 | 2022-09-01 20:57:29 | [diff] [blame] | 331 | --bundle-uri=<uri>:: |
| 332 | Before fetching from the remote, fetch a bundle from the given |
| 333 | `<uri>` and unbundle the data into the local repository. The refs |
| 334 | in the bundle will be stored under the hidden `refs/bundle/*` |
| 335 | namespace. This option is incompatible with `--depth`, |
| 336 | `--shallow-since`, and `--shallow-exclude`. |
| 337 | |
Junio C Hamano | 63777e2 | 2007-11-17 20:52:16 | [diff] [blame] | 338 | :git-clone: 1 |
Junio C Hamano | 330aae6 | 2007-07-06 17:01:58 | [diff] [blame] | 339 | include::urls.txt[] |
| 340 | |
Junio C Hamano | b9d9d90 | 2018-05-23 07:07:42 | [diff] [blame] | 341 | EXAMPLES |
Junio C Hamano | 1bb569e | 2006-05-05 23:14:25 | [diff] [blame] | 342 | -------- |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 343 | |
Junio C Hamano | 9ccf664 | 2010-03-22 01:47:35 | [diff] [blame] | 344 | * Clone from upstream: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 345 | + |
| 346 | ------------ |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 347 | $ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux |
| 348 | $ cd my-linux |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 349 | $ make |
| 350 | ------------ |
| 351 | |
| 352 | |
Junio C Hamano | 9ccf664 | 2010-03-22 01:47:35 | [diff] [blame] | 353 | * 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] | 354 | + |
| 355 | ------------ |
| 356 | $ git clone -l -s -n . ../copy |
Junio C Hamano | 8638c92 | 2007-05-12 20:50:08 | [diff] [blame] | 357 | $ cd ../copy |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 358 | $ git show-branch |
| 359 | ------------ |
| 360 | |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 361 | |
Junio C Hamano | 9ccf664 | 2010-03-22 01:47:35 | [diff] [blame] | 362 | * Clone from upstream while borrowing from an existing local directory: |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 363 | + |
| 364 | ------------ |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 365 | $ git clone --reference /git/linux.git \ |
| 366 | git://git.kernel.org/pub/scm/.../linux.git \ |
| 367 | my-linux |
| 368 | $ cd my-linux |
Junio C Hamano | f50bfec | 2006-04-19 09:44:12 | [diff] [blame] | 369 | ------------ |
| 370 | |
| 371 | |
Junio C Hamano | 9ccf664 | 2010-03-22 01:47:35 | [diff] [blame] | 372 | * Create a bare repository to publish your changes to the public: |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 373 | + |
| 374 | ------------ |
Junio C Hamano | e663a7a | 2006-01-25 12:37:28 | [diff] [blame] | 375 | $ git clone --bare -l /home/proj/.git /pub/scm/proj.git |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 376 | ------------ |
| 377 | |
Junio C Hamano | ba8baee | 2022-09-14 20:25:23 | [diff] [blame] | 378 | CONFIGURATION |
| 379 | ------------- |
| 380 | |
| 381 | include::includes/cmd-config-section-all.txt[] |
| 382 | |
| 383 | include::config/init.txt[] |
| 384 | |
| 385 | include::config/clone.txt[] |
| 386 | |
Junio C Hamano | 38064d5 | 2006-01-15 10:13:49 | [diff] [blame] | 387 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 388 | GIT |
| 389 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 390 | Part of the linkgit:git[1] suite |