Skip to content

Commit 23b3625

Browse files
committed
Merge branch 'tc/clone-single-revision' into jch
"git clone" learned to make a shallow clone for a single commit that is not necessarily be at the tip of any branch. * tc/clone-single-revision: fixup! builtin/clone: teach git-clone(1) the --revision= option builtin/clone: teach git-clone(1) the --revision= option clone: introduce struct clone_opts in builtin/clone.c clone: add tags refspec earlier to fetch refspec clone: refactor wanted_peer_refs() clone: make it possible to specify --tags clone: cut down on global variables in clone.c
2 parents d6344f1 + 8dedf1e commit 23b3625

File tree

7 files changed

+345
-153
lines changed

7 files changed

+345
-153
lines changed

Documentation/git-clone.adoc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ git clone [--template=<template-directory>]
1313
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
1414
[-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
1515
[--dissociate] [--separate-git-dir <git-dir>]
16-
[--depth <depth>] [--[no-]single-branch] [--no-tags]
16+
[--depth <depth>] [--[no-]single-branch] [--[no-]-tags]
1717
[--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules]
1818
[--[no-]remote-submodules] [--jobs <n>] [--sparse] [--[no-]reject-shallow]
1919
[--filter=<filter-spec>] [--also-filter-submodules]] [--] <repository>
@@ -221,6 +221,16 @@ objects from the source repository into a pack in the cloned repository.
221221
`--branch` can also take tags and detaches the `HEAD` at that commit
222222
in the resulting repository.
223223

224+
`--revision` _<rev>_::
225+
Create a new repository, and fetch the history leading to the given
226+
revision _<rev>_ (and nothing else), without making any remote-tracking
227+
branch, and without making any local branch, and point `HEAD` to
228+
_<rev>_. When creating a non-bare repository, the revision is checked
229+
out on a detached `HEAD`. The argument can be a ref name
230+
(e.g. `refs/heads/main` or `refs/tags/v1.0`) that peels down to a
231+
commit, or a hexadecimal object name.
232+
This option is incompatible with `--branch` and `--mirror`.
233+
224234
`-u` _<upload-pack>_::
225235
`--upload-pack` _<upload-pack>_::
226236
When given, and the repository to clone from is accessed
@@ -273,8 +283,9 @@ corresponding `--mirror` and `--no-tags` options instead.
273283
branch when `--single-branch` clone was made, no remote-tracking
274284
branch is created.
275285

276-
`--no-tags`::
277-
Don't clone any tags, and set
286+
`--[no-]tags`::
287+
By default tags are cloned, and passing `--tags` doesn't change that.
288+
With `--no-tags`, no tags are cloned, and set
278289
`remote.<remote>.tagOpt=--no-tags` in the config, ensuring
279290
that future `git pull` and `git fetch` operations won't follow
280291
any tags. Subsequent explicit tag fetches will still work,

0 commit comments

Comments
 (0)