Skip to content

Commit 5785d91

Browse files
committed
Merge branch 'tc/clone-single-revision'
"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: builtin/clone: teach git-clone(1) the --revision= option parse-options: introduce die_for_incompatible_opt2() 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 0cc1300 + 3378556 commit 5785d91

File tree

8 files changed

+357
-165
lines changed

8 files changed

+357
-165
lines changed

Documentation/git-clone.adoc

Lines changed: 19 additions & 7 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,15 @@ 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 detach `HEAD` to
228+
_<rev>_. The argument can be a ref name (e.g. `refs/heads/main` or
229+
`refs/tags/v1.0`) that peels down to a commit, or a hexadecimal object
230+
name.
231+
This option is incompatible with `--branch` and `--mirror`.
232+
224233
`-u` _<upload-pack>_::
225234
`--upload-pack` _<upload-pack>_::
226235
When given, and the repository to clone from is accessed
@@ -273,12 +282,15 @@ corresponding `--mirror` and `--no-tags` options instead.
273282
branch when `--single-branch` clone was made, no remote-tracking
274283
branch is created.
275284

276-
`--no-tags`::
277-
Don't clone any tags, and set
278-
`remote.<remote>.tagOpt=--no-tags` in the config, ensuring
279-
that future `git pull` and `git fetch` operations won't follow
280-
any tags. Subsequent explicit tag fetches will still work,
281-
(see linkgit:git-fetch[1]).
285+
`--[no-]tags`::
286+
Control whether or not tags will be cloned. When `--no-tags` is
287+
given, the option will be become permanent by setting the
288+
`remote.<remote>.tagOpt=--no-tags` configuration. This ensures that
289+
future `git pull` and `git fetch` won't follow any tags. Subsequent
290+
explicit tag fetches will still work (see linkgit:git-fetch[1]).
291+
292+
By default, tags are cloned and passing `--tags` is thus typically a
293+
no-op, unless it cancels out a previous `--no-tags`.
282294
+
283295
Can be used in conjunction with `--single-branch` to clone and
284296
maintain a branch with no references other than a single cloned

0 commit comments

Comments
 (0)