Home Explore Blog CI



git

6th chunk of `Documentation/git-clone.adoc`
f8b1271dcda864e3f4ee29437debcb03606cddf8e88dd0d20000000100000ce2
 consisting
	of multiple entries.  The resulting clone has `submodule.active` set to
	the provided pathspec, or "`.`" (meaning all submodules) if no
	pathspec is provided.
+
Submodules are initialized and cloned using their default settings. This is
equivalent to running
`git submodule update --init --recursive <pathspec>` immediately after
the clone is finished. This option is ignored if the cloned repository does
not have a worktree/checkout (i.e. if any of `--no-checkout`/`-n`, `--bare`,
or `--mirror` is given)

`--[no-]shallow-submodules`::
	All submodules which are cloned will be shallow with a depth of 1.

`--[no-]remote-submodules`::
	All submodules which are cloned will use the status of the submodule's
	remote-tracking branch to update the submodule, rather than the
	superproject's recorded SHA-1. Equivalent to passing `--remote` to
	`git submodule update`.

`--separate-git-dir=<git-dir>`::
	Instead of placing the cloned repository where it is supposed
	to be, place the cloned repository at the specified directory,
	then make a filesystem-agnostic Git symbolic link to there.
	The result is Git repository can be separated from working
	tree.

`--ref-format=<ref-format>`::

Specify the given ref storage format for the repository. The valid values are:
+
include::ref-storage-format.adoc[]

`-j` _<n>_::
`--jobs` _<n>_::
	The number of submodules fetched at the same time.
	Defaults to the `submodule.fetchJobs` option.

_<repository>_::
	The (possibly remote) _<repository>_ to clone from.  See the
	<<URLS,GIT URLS>> section below for more information on specifying
	repositories.

_<directory>_::
	The name of a new directory to clone into.  The "humanish"
	part of the source repository is used if no _<directory>_ is
	explicitly given (`repo` for `/path/to/repo.git` and `foo`
	for `host.xz:foo/.git`).  Cloning into an existing directory
	is only allowed if the directory is empty.

`--bundle-uri=<uri>`::
	Before fetching from the remote, fetch a bundle from the given
	_<uri>_ and unbundle the data into the local repository. The refs
	in the bundle will be stored under the hidden `refs/bundle/*`
	namespace. This option is incompatible with `--depth`,
	`--shallow-since`, and `--shallow-exclude`.

:git-clone: 1
include::urls.adoc[]

EXAMPLES
--------

* Clone from upstream:
+
------------
$ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux
$ cd my-linux
$ make
------------


* Make a local clone that borrows from the current directory, without checking things out:
+
------------
$ git clone -l -s -n . ../copy
$ cd ../copy
$ git show-branch
------------


* Clone from upstream while borrowing from an existing local directory:
+
------------
$ git clone --reference /git/linux.git \
	git://git.kernel.org/pub/scm/.../linux.git \
	my-linux
$ cd my-linux
------------


* Create a bare repository to publish your changes to the public:
+
------------
$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
------------

* Clone a local repository from a different user:
+
------------
$ git clone --no-local /home/otheruser/proj.git /pub/scm/proj.git
------------

CONFIGURATION
-------------

include::includes/cmd-config-section-all.adoc[]

include::config/init.adoc[]

include::config/clone.adoc[]


GIT
---
Part of the linkgit:git[1] suite

Title: Git Clone Command Options and Examples
Summary
The git clone command offers various options to customize the cloning process, including submodule handling, ref format, and repository separation, with examples demonstrating how to use these options for different use cases, such as cloning from upstream, creating bare repositories, and borrowing from local directories.