This is an old revision of the document!
Overview
Basic and advanced features of cloning.
Shallow clones
Read all about it here.
Synopsis:
--depth <depth>
Create a shallow clone with a history truncated to the
specified number of commits. Implies --single-branch unless
--no-single-branch is given to fetch the histories near the
tips of all branches. If you want to clone submodules
shallowly, also pass --shallow-submodules.
--shallow-since=<date>
Create a shallow clone with a history after the specified
time.
--shallow-exclude=<revision>
Create a shallow clone with a history, excluding commits
reachable from a specified remote branch or tag. This
option can be specified multiple times.
--[no-]single-branch
Clone only the history leading to the tip of a single
branch, either specified by the --branch option or the
primary branch remote’s HEAD points at. Further fetches
into the resulting repository will only update the
remote-tracking branch for the branch this option was used
for the initial cloning. If the HEAD at the remote did not
point at any branch when --single-branch clone was made, no
remote-tracking branch is created.
--no-tags
Don’t clone any tags, and set
remote.<remote>.tagOpt=--no-tags in the config, ensuring
that future git pull and git fetch operations won’t follow
any tags. Subsequent explicit tag fetches will still work,
(see git-fetch(1)).
Can be used in conjunction with --single-branch to clone
and maintain a branch with no references other than a
single cloned branch. This is useful e.g. to maintain
minimal clones of the default branch of some repository for
search indexing.
$ git clone --depth 1 <repo URL>