GIT-CLONE(1) Git Manual GIT-CLONE(1)
NAME
git-clone - Clone a repository into a new directory
SYNOPSIS
git clone [--template=]
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
[-o ] [-b ] [-u ] [--reference ]
[--dissociate] [--separate-git-dir ]
[--depth ] [--[no-]single-branch] [--[no-]tags]
[--recurse-submodules[=]] [--[no-]shallow-submodules]
[--[no-]remote-submodules] [--jobs ] [--sparse] [--[no-]reject-shallow]
[--filter= [--also-filter-submodules]] [--]
[]
DESCRIPTION
Clones a repository into a newly created directory, creates remote-tracking branches for each branch
in the cloned repository (visible using git branch --remotes), and creates and checks out an initial
branch that is forked from the cloned repositoryâs currently active branch.
After the clone, a plain git fetch without arguments will update all the remote-tracking branches,
and a git pull without arguments will in addition merge the remote master branch into the current
master branch, if any (this is untrue when --single-branch is given; see below).
This default configuration is achieved by creating references to the remote branch heads under
refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration
variables.
OPTIONS
-l, --local
When the repository to clone from is on a local machine, this flag bypasses the normal "Git
aware" transport mechanism and clones the repository by making a copy of HEAD and everything
under objects and refs directories. The files under .git/objects/ directory are hardlinked to
save space when possible.
If the repository is specified as a local path (e.g., /path/to/repo), this is the default, and
--local is essentially a no-op. If the repository is specified as a URL, then this flag is
ignored (and we never use the local optimizations). Specifying --no-local will override the
default when /path/to/repo is given, using the regular Git transport instead.
If the repositoryâs $GIT_DIR/objects has symbolic links or is a symbolic link, the clone will
fail. This is a security measure to prevent the unintentional copying of files by dereferencing
the symbolic links.
This option does not work with repositories owned by other users for security reasons, and
--no-local must be specified for the clone to succeed.
NOTE: this operation can race with concurrent modification to the source repository, similar to
running cp -r while modifying .
--no-hardlinks
Force the cloning process from a repository on a local filesystem to copy the files under the
.git/objects directory instead of using hardlinks. This may be desirable if you are trying to
make a back-up of your repository.
-s, --shared
When the repository to clone is on the local machine, instead of using hard links, automatically
setup .git/objects/info/alternates to share the objects with the source repository. The resulting
repository starts out without any object of its own.
NOTE: this is a possibly dangerous operation; do not use it unless you understand what it does.
If you clone your repository using this option and then delete branches (or use any other Git
command that makes any existing commit unreferenced) in the source repository, some objects may
become unreferenced (or dangling). These objects may be removed by normal Git operations (such as
git commit) which automatically call git maintenance run --auto. (See git-maintenance(1).) If
these objects are removed and were referenced by the cloned repository, then the cloned
repository will become corrupt.
Note that running git repack without the --local option in a repository cloned with --shared will
copy objects from the source repository into a pack in the cloned repository, removing the disk
space savings of clone --shared. It is safe, however, to run git gc, which uses the --local
option by default.
If you want to break the dependency of a repository cloned with --shared on its source
repository, you can simply run git repack -a to copy all objects from the source repository into
a pack in the cloned repository.
--reference[-if-able]
If the reference is on the local machine, automatically setup
.git/objects/info/alternates to obtain objects from the reference . Using an already
existing repository as an alternate will require fewer objects to be copied from the repository
being cloned, reducing network and local storage costs. When using the --reference-if-able, a non
existing directory is skipped with a warning instead of aborting the clone.
NOTE: see the NOTE for the --shared option, and also the --dissociate option.
--dissociate
Borrow the objects from reference repositories specified with the --reference options only to
reduce network transfer, and stop borrowing from them after a clone is made by making necessary
local copies of borrowed objects. This option can also be used when cloning locally from a
repository that already borrows objects from another repositoryâthe new repository will borrow
objects from the same repository, and this option can be used to stop the borrowing.
-q, --quiet
Operate quietly. Progress is not reported to the standard error stream.
-v, --verbose
Run verbosely. Does not affect the reporting of progress status to the standard error stream.
--progress
Progress status is reported on the standard error stream by default when it is attached to a
terminal, unless --quiet is specified. This flag forces progress status even if the standard
error stream is not directed to a terminal.
--server-option=