Imported Upstream version 2.16.0
[platform/upstream/git.git] / Documentation / git-clone.txt
index 6e22522..42ca7b5 100644 (file)
@@ -12,10 +12,10 @@ SYNOPSIS
 'git clone' [--template=<template_directory>]
          [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
          [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
-         [--separate-git-dir <git dir>]
-         [--depth <depth>] [--[no-]single-branch]
-         [--recursive|--recurse-submodules] [--] <repository>
-         [<directory>]
+         [--dissociate] [--separate-git-dir <git dir>]
+         [--depth <depth>] [--[no-]single-branch] [--no-tags]
+         [--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules]
+         [--jobs <n>] [--] <repository> [<directory>]
 
 DESCRIPTION
 -----------
@@ -29,7 +29,8 @@ 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.
+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
@@ -42,22 +43,24 @@ OPTIONS
 --local::
 -l::
        When the repository to clone from is on a local machine,
-       this flag bypasses the normal "git aware" transport
+       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.  This is now the default when
-       the source repository is specified with `/path/to/repo`
-       syntax, so it essentially is a no-op option.  To force
-       copying instead of hardlinking (which may be desirable
-       if you are trying to make a back-up of your repository),
-       but still avoid the usual "git aware" transport
-       mechanism, `--no-hardlinks` can be used.
+       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.
 
 --no-hardlinks::
-       Optimize the cloning process from a repository on a
-       local filesystem by copying files under `.git/objects`
-       directory.
+       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.
 
 --shared::
 -s::
@@ -70,9 +73,9 @@ OPTIONS
 *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
+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`)
+These objects may be removed by normal Git operations (such as `git commit`)
 which automatically call `git gc --auto`. (See linkgit:git-gc[1].)
 If these objects are removed and were referenced by the cloned repository,
 then the cloned repository will become corrupt.
@@ -87,21 +90,35 @@ If you want to break the dependency of a repository cloned with `-s` 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 <repository>::
+--reference[-if-able] <repository>::
        If the reference repository is on the local machine,
        automatically setup `.git/objects/info/alternates` to
        obtain objects from the reference repository.  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.
+*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.
 
 --quiet::
 -q::
        Operate quietly.  Progress is not reported to the standard
-       error stream. This flag is also passed to the `rsync'
-       command when given.
+       error stream.
 
 --verbose::
 -v::
@@ -119,7 +136,7 @@ objects from the source repository into a pack in the cloned repository.
        No checkout of HEAD is performed after the clone is complete.
 
 --bare::
-       Make a 'bare' GIT repository.  That is, instead of
+       Make a 'bare' Git repository.  That is, instead of
        creating `<directory>` and placing the administrative
        files in `<directory>/.git`, make the `<directory>`
        itself the `$GIT_DIR`. This obviously implies the `-n`
@@ -147,9 +164,10 @@ objects from the source repository into a pack in the cloned repository.
 -b <name>::
        Instead of pointing the newly created HEAD to the branch pointed
        to by the cloned repository's HEAD, point to `<name>` branch
-       instead. `--branch` can also take tags and treat them like
-       detached HEAD. In a non-bare repository, this is the branch
-       that will be checked out.
+       instead. In a non-bare repository, this is the branch that will
+       be checked out.
+       `--branch` can also take tags and detaches the HEAD at that commit
+       in the resulting repository.
 
 --upload-pack <upload-pack>::
 -u <upload-pack>::
@@ -174,37 +192,71 @@ objects from the source repository into a pack in the cloned repository.
 
 --depth <depth>::
        Create a 'shallow' clone with a history truncated to the
-       specified number of revisions.  A shallow repository has a
-       number of limitations (you cannot clone or fetch from
-       it, nor push from nor into it), but is adequate if you
-       are only interested in the recent history of a large project
-       with a long history, and would want to send in fixes
-       as patches.
-
---single-branch::
+       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. When creating a shallow
-       clone with the `--depth` option, this is the default, unless
-       `--no-single-branch` is given to fetch the histories near the
-       tips of all branches.
+       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 linkgit: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.
+
+--recurse-submodules[=<pathspec]::
+       After the clone is created, initialize and clone submodules
+       within based on the provided pathspec.  If no pathspec is
+       provided, all submodules are initialized and cloned.
+       This option can be given multiple times for pathspecs 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)
 
---recursive::
---recurse-submodules::
-       After the clone is created, initialize all submodules within,
-       using their default settings. This is equivalent to running
-       `git submodule update --init --recursive` 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.
 
 --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 filesytem-agnostic git symbolic link to there.
-       The result is git repository can be separated from working
+       then make a filesystem-agnostic Git symbolic link to there.
+       The result is Git repository can be separated from working
        tree.
 
+-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
@@ -227,8 +279,8 @@ Examples
 * Clone from upstream:
 +
 ------------
-$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
-$ cd my2.6
+$ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux
+$ cd my-linux
 $ make
 ------------
 
@@ -245,10 +297,10 @@ $ git show-branch
 * Clone from upstream while borrowing from an existing local directory:
 +
 ------------
-$ git clone --reference my2.6 \
-       git://git.kernel.org/pub/scm/.../linux-2.7 \
-       my2.7
-$ cd my2.7
+$ git clone --reference /git/linux.git \
+       git://git.kernel.org/pub/scm/.../linux.git \
+       my-linux
+$ cd my-linux
 ------------
 
 
@@ -259,13 +311,6 @@ $ git clone --bare -l /home/proj/.git /pub/scm/proj.git
 ------------
 
 
-* Create a repository on the kernel.org machine that borrows from Linus:
-+
-------------
-$ git clone --bare -l -s /pub/scm/.../torvalds/linux-2.6.git \
-    /pub/scm/.../me/subsys-2.6.git
-------------
-
 GIT
 ---
 Part of the linkgit:git[1] suite