<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect2 SYSTEM "../../../dtd/dblite.dtd">

<sect2 lang="en" id="git-clone(1)">
    <title>git-clone(1)</title>
    <date>2024-07-02</date>
<revhistory><revision><date>2024-07-02</date></revision></revhistory>
<indexterm>
<primary>git-clone(1)</primary>
</indexterm>
<simplesect id="git-clone(1)__name">
<title>NAME</title>
<simpara>git-clone - Clone a repository into a new directory</simpara>
</simplesect>
<simplesect id="git-clone(1)__synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git clone</emphasis> [<literal>--template=</literal><emphasis>&lt;template-directory&gt;</emphasis>]
          [<emphasis>-l</emphasis>] [<emphasis>-s</emphasis>] [<emphasis>--no-hardlinks</emphasis>] [<emphasis>-q</emphasis>] [<emphasis>-n</emphasis>] [<emphasis>--bare</emphasis>] [<emphasis>--mirror</emphasis>]
          [<emphasis>-o</emphasis> <emphasis>&lt;name&gt;</emphasis>] [<emphasis>-b</emphasis> <emphasis>&lt;name&gt;</emphasis>] [<emphasis>-u</emphasis> <emphasis>&lt;upload-pack&gt;</emphasis>] [<emphasis>--reference</emphasis> <emphasis>&lt;repository&gt;</emphasis>]
          [<emphasis>--dissociate</emphasis>] [<emphasis>--separate-git-dir</emphasis> <emphasis>&lt;git-dir&gt;</emphasis>]
          [<emphasis>--depth</emphasis> <emphasis>&lt;depth&gt;</emphasis>] [<emphasis>--</emphasis>[<emphasis>no-</emphasis>]<emphasis>single-branch</emphasis>] [<emphasis>--no-tags</emphasis>]
          [<literal>--recurse-submodules</literal>[<literal>=</literal><emphasis>&lt;pathspec&gt;</emphasis>]] [<emphasis>--</emphasis>[<emphasis>no-</emphasis>]<emphasis>shallow-submodules</emphasis>]
          [<emphasis>--</emphasis>[<emphasis>no-</emphasis>]<emphasis>remote-submodules</emphasis>] [<emphasis>--jobs</emphasis> <emphasis>&lt;n&gt;</emphasis>] [<emphasis>--sparse</emphasis>] [<emphasis>--</emphasis>[<emphasis>no-</emphasis>]<emphasis>reject-shallow</emphasis>]
          [<literal>--filter=</literal><emphasis>&lt;filter-spec&gt;</emphasis>] [<emphasis>--also-filter-submodules</emphasis>]] [<emphasis>--</emphasis>] <emphasis>&lt;repository&gt;</emphasis>
          [<emphasis>&lt;directory&gt;</emphasis>]</literallayout>
</blockquote>
</simplesect>
<simplesect id="git-clone(1)__description">
<title>DESCRIPTION</title>
<simpara>Clones a repository into a newly created directory, creates
remote-tracking branches for each branch in the cloned repository
(visible using <emphasis>git branch --remotes</emphasis>), and creates and checks out an
initial branch that is forked from the cloned repository's
currently active branch.</simpara>
<simpara>After the clone, a plain <emphasis>git fetch</emphasis> without arguments will update
all the remote-tracking branches, and a <emphasis>git pull</emphasis> without
arguments will in addition merge the remote master branch into the
current master branch, if any (this is untrue when <emphasis>--single-branch</emphasis>
is given; see below).</simpara>
<simpara>This default configuration is achieved by creating references to
the remote branch heads under <emphasis>refs/remotes/origin</emphasis> and
by initializing <emphasis>remote.origin.url</emphasis> and <emphasis>remote.origin.fetch</emphasis>
configuration variables.</simpara>
</simplesect>
<simplesect id="git-clone(1)__options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
<emphasis>-l</emphasis>
</term>
<term>
<emphasis>--local</emphasis>
</term>
<listitem>
<simpara>
        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
        <emphasis>HEAD</emphasis> and everything under objects and refs directories.
        The files under <emphasis>.git/objects/</emphasis> directory are hardlinked
        to save space when possible.
</simpara>
<simpara>If the repository is specified as a local path (e.g., <emphasis>/path/to/repo</emphasis>),
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 <emphasis>--no-local</emphasis> will
override the default when <emphasis>/path/to/repo</emphasis> is given, using the regular
Git transport instead.</simpara>
<simpara>If the repository's <emphasis>$GIT_DIR/objects</emphasis> 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.</simpara>
<simpara><emphasis role="strong">NOTE</emphasis>: this operation can race with concurrent modification to the
source repository, similar to running <emphasis>cp -r src dst</emphasis> while modifying
<emphasis>src</emphasis>.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--no-hardlinks</emphasis>
</term>
<listitem>
<simpara>
        Force the cloning process from a repository on a local
        filesystem to copy the files under the <emphasis>.git/objects</emphasis>
        directory instead of using hardlinks. This may be desirable
        if you are trying to make a back-up of your repository.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-s</emphasis>
</term>
<term>
<emphasis>--shared</emphasis>
</term>
<listitem>
<simpara>
        When the repository to clone is on the local machine,
        instead of using hard links, automatically setup
        <emphasis>.git/objects/info/alternates</emphasis> to share the objects
        with the source repository.  The resulting repository
        starts out without any object of its own.
</simpara>
<simpara><emphasis role="strong">NOTE</emphasis>: this is a possibly dangerous operation; do <emphasis role="strong">not</emphasis> 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 <emphasis>git commit</emphasis>)
which automatically call <emphasis>git maintenance run --auto</emphasis>. (See
<xref linkend="git-maintenance(1)" />.) If these objects are removed and were referenced
by the cloned repository, then the cloned repository will become corrupt.</simpara>
<simpara>Note that running <emphasis>git repack</emphasis> without the <emphasis>--local</emphasis> option in a repository
cloned with <emphasis>--shared</emphasis> will copy objects from the source repository into a pack
in the cloned repository, removing the disk space savings of <emphasis>clone --shared</emphasis>.
It is safe, however, to run <emphasis>git gc</emphasis>, which uses the <emphasis>--local</emphasis> option by
default.</simpara>
<simpara>If you want to break the dependency of a repository cloned with <emphasis>--shared</emphasis> on
its source repository, you can simply run <emphasis>git repack -a</emphasis> to copy all
objects from the source repository into a pack in the cloned repository.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--reference</emphasis>[<emphasis>-if-able</emphasis>] <emphasis>&lt;repository&gt;</emphasis>
</term>
<listitem>
<simpara>
        If the reference <emphasis>&lt;repository&gt;</emphasis> is on the local machine,
        automatically setup <emphasis>.git/objects/info/alternates</emphasis> to
        obtain objects from the reference <emphasis>&lt;repository&gt;</emphasis>.  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 <emphasis>--reference-if-able</emphasis>, a non existing
        directory is skipped with a warning instead of aborting
        the clone.
</simpara>
<simpara><emphasis role="strong">NOTE</emphasis>: see the NOTE for the <emphasis>--shared</emphasis> option, and also the
<emphasis>--dissociate</emphasis> option.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--dissociate</emphasis>
</term>
<listitem>
<simpara>
        Borrow the objects from reference repositories specified
        with the <emphasis>--reference</emphasis> 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.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-q</emphasis>
</term>
<term>
<emphasis>--quiet</emphasis>
</term>
<listitem>
<simpara>
        Operate quietly.  Progress is not reported to the standard
        error stream.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-v</emphasis>
</term>
<term>
<emphasis>--verbose</emphasis>
</term>
<listitem>
<simpara>
        Run verbosely. Does not affect the reporting of progress status
        to the standard error stream.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--progress</emphasis>
</term>
<listitem>
<simpara>
        Progress status is reported on the standard error stream
        by default when it is attached to a terminal, unless <emphasis>--quiet</emphasis>
        is specified. This flag forces progress status even if the
        standard error stream is not directed to a terminal.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>--server-option=</literal><emphasis>&lt;option&gt;</emphasis>
</term>
<listitem>
<simpara>
        Transmit the given string to the server when communicating using
        protocol version 2.  The given string must not contain a NUL or LF
        character.  The server's handling of server options, including
        unknown ones, is server-specific.
        When multiple <literal>--server-option=</literal><emphasis>&lt;option&gt;</emphasis> are given, they are all
        sent to the other side in the order listed on the command line.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-n</emphasis>
</term>
<term>
<emphasis>--no-checkout</emphasis>
</term>
<listitem>
<simpara>
        No checkout of HEAD is performed after the clone is complete.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--</emphasis>[<emphasis>no-</emphasis>]<emphasis>reject-shallow</emphasis>
</term>
<listitem>
<simpara>
        Fail if the source repository is a shallow repository.
        The <emphasis>clone.rejectShallow</emphasis> configuration variable can be used to
        specify the default.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--bare</emphasis>
</term>
<listitem>
<simpara>
        Make a <emphasis>bare</emphasis> Git repository.  That is, instead of
        creating <emphasis>&lt;directory&gt;</emphasis> and placing the administrative
        files in <emphasis>&lt;directory&gt;</emphasis><emphasis>/.git</emphasis>, make the <emphasis>&lt;directory&gt;</emphasis>
        itself the <emphasis>$GIT_DIR</emphasis>. This obviously implies the <emphasis>--no-checkout</emphasis>
        because there is nowhere to check out the working tree.
        Also the branch heads at the remote are copied directly
        to corresponding local branch heads, without mapping
        them to <emphasis>refs/remotes/origin/</emphasis>.  When this option is
        used, neither remote-tracking branches nor the related
        configuration variables are created.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--sparse</emphasis>
</term>
<listitem>
<simpara>
        Employ a sparse-checkout, with only files in the toplevel
        directory initially being present.  The
        <xref linkend="git-sparse-checkout(1)" /> command can be used to grow the
        working directory as needed.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>--filter=</literal><emphasis>&lt;filter-spec&gt;</emphasis>
</term>
<listitem>
<simpara>
        Use the partial clone feature and request that the server sends
        a subset of reachable objects according to a given object filter.
        When using <emphasis>--filter</emphasis>, the supplied <emphasis>&lt;filter-spec&gt;</emphasis> is used for
        the partial clone filter. For example, <emphasis>--filter=blob:none</emphasis> will
        filter out all blobs (file contents) until needed by Git. Also,
        <literal>--filter=blob:limit=</literal><emphasis>&lt;size&gt;</emphasis> will filter out all blobs of size
        at least <emphasis>&lt;size&gt;</emphasis>. For more details on filter specifications, see
        the <emphasis>--filter</emphasis> option in <xref linkend="git-rev-list(1)" />.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--also-filter-submodules</emphasis>
</term>
<listitem>
<simpara>
        Also apply the partial clone filter to any submodules in the repository.
        Requires <emphasis>--filter</emphasis> and <emphasis>--recurse-submodules</emphasis>. This can be turned on by
        default by setting the <emphasis>clone.filterSubmodules</emphasis> config option.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--mirror</emphasis>
</term>
<listitem>
<simpara>
        Set up a mirror of the source repository.  This implies <emphasis>--bare</emphasis>.
        Compared to <emphasis>--bare</emphasis>, <emphasis>--mirror</emphasis> not only maps local branches of the
        source to local branches of the target, it maps all refs (including
        remote-tracking branches, notes etc.) and sets up a refspec configuration such
        that all these refs are overwritten by a <emphasis>git remote update</emphasis> in the
        target repository.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-o</emphasis> <emphasis>&lt;name&gt;</emphasis>
</term>
<term>
<emphasis>--origin</emphasis> <emphasis>&lt;name&gt;</emphasis>
</term>
<listitem>
<simpara>
        Instead of using the remote name <emphasis>origin</emphasis> to keep track of the upstream
        repository, use <emphasis>&lt;name&gt;</emphasis>.  Overrides <emphasis>clone.defaultRemoteName</emphasis> from the
        config.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-b</emphasis> <emphasis>&lt;name&gt;</emphasis>
</term>
<term>
<emphasis>--branch</emphasis> <emphasis>&lt;name&gt;</emphasis>
</term>
<listitem>
<simpara>
        Instead of pointing the newly created HEAD to the branch pointed
        to by the cloned repository's HEAD, point to <emphasis>&lt;name&gt;</emphasis> branch
        instead. In a non-bare repository, this is the branch that will
        be checked out.
        <emphasis>--branch</emphasis> can also take tags and detaches the HEAD at that commit
        in the resulting repository.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-u</emphasis> <emphasis>&lt;upload-pack&gt;</emphasis>
</term>
<term>
<emphasis>--upload-pack</emphasis> <emphasis>&lt;upload-pack&gt;</emphasis>
</term>
<listitem>
<simpara>
        When given, and the repository to clone from is accessed
        via ssh, this specifies a non-default path for the command
        run on the other end.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>--template=</literal><emphasis>&lt;template-directory&gt;</emphasis>
</term>
<listitem>
<simpara>
        Specify the directory from which templates will be used;
        (See the "TEMPLATE DIRECTORY" section of <xref linkend="git-init(1)" />.)
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-c</emphasis> <emphasis>&lt;key&gt;</emphasis><literal>=</literal><emphasis>&lt;value&gt;</emphasis>
</term>
<term>
<emphasis>--config</emphasis> <emphasis>&lt;key&gt;</emphasis><literal>=</literal><emphasis>&lt;value&gt;</emphasis>
</term>
<listitem>
<simpara>
        Set a configuration variable in the newly-created repository;
        this takes effect immediately after the repository is
        initialized, but before the remote history is fetched or any
        files checked out.  The <emphasis>&lt;key&gt;</emphasis> is in the same format as expected by
        <xref linkend="git-config(1)" /> (e.g., <emphasis>core.eol=true</emphasis>). If multiple
        values are given for the same key, each value will be written to
        the config file. This makes it safe, for example, to add
        additional fetch refspecs to the origin remote.
</simpara>
<simpara>Due to limitations of the current implementation, some configuration
variables do not take effect until after the initial fetch and checkout.
Configuration variables known to not take effect are:
<literal>remote.</literal><emphasis>&lt;name&gt;</emphasis><literal>.mirror</literal> and <literal>remote.</literal><emphasis>&lt;name&gt;</emphasis><literal>.tagOpt</literal>.  Use the
corresponding <emphasis>--mirror</emphasis> and <emphasis>--no-tags</emphasis> options instead.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--depth</emphasis> <emphasis>&lt;depth&gt;</emphasis>
</term>
<listitem>
<simpara>
        Create a <emphasis>shallow</emphasis> clone with a history truncated to the
        specified number of commits. Implies <emphasis>--single-branch</emphasis> unless
        <emphasis>--no-single-branch</emphasis> is given to fetch the histories near the
        tips of all branches. If you want to clone submodules shallowly,
        also pass <emphasis>--shallow-submodules</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>--shallow-since=</literal><emphasis>&lt;date&gt;</emphasis>
</term>
<listitem>
<simpara>
        Create a shallow clone with a history after the specified time.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>--shallow-exclude=</literal><emphasis>&lt;revision&gt;</emphasis>
</term>
<listitem>
<simpara>
        Create a shallow clone with a history, excluding commits
        reachable from a specified remote branch or tag.  This option
        can be specified multiple times.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--</emphasis>[<emphasis>no-</emphasis>]<emphasis>single-branch</emphasis>
</term>
<listitem>
<simpara>
        Clone only the history leading to the tip of a single branch,
        either specified by the <emphasis>--branch</emphasis> option or the primary
        branch remote's <emphasis>HEAD</emphasis> 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 <emphasis>HEAD</emphasis> at the remote did not point at any
        branch when <emphasis>--single-branch</emphasis> clone was made, no remote-tracking
        branch is created.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--no-tags</emphasis>
</term>
<listitem>
<simpara>
        Don't clone any tags, and set
        <emphasis>remote.&lt;remote&gt;.tagOpt=--no-tags</emphasis> in the config, ensuring
        that future <emphasis>git pull</emphasis> and <emphasis>git fetch</emphasis> operations won't follow
        any tags. Subsequent explicit tag fetches will still work,
        (see <xref linkend="git-fetch(1)" />).
</simpara>
<simpara>Can be used in conjunction with <emphasis>--single-branch</emphasis> 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.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--recurse-submodules</emphasis>[<emphasis>=</emphasis><emphasis>&lt;pathspec&gt;</emphasis>]
</term>
<listitem>
<simpara>
        After the clone is created, initialize and clone submodules
        within based on the provided <emphasis>&lt;pathspec&gt;</emphasis>.  If no <emphasis>=&lt;pathspec&gt;</emphasis> 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 <emphasis>submodule.active</emphasis> set to
        the provided pathspec, or "." (meaning all submodules) if no
        pathspec is provided.
</simpara>
<simpara>Submodules are initialized and cloned using their default settings. This is
equivalent to running
<emphasis>git submodule update --init --recursive &lt;pathspec&gt;</emphasis> 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 <emphasis>--no-checkout</emphasis>/<emphasis>-n</emphasis>, <emphasis>--bare</emphasis>,
or <emphasis>--mirror</emphasis> is given)</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--</emphasis>[<emphasis>no-</emphasis>]<emphasis>shallow-submodules</emphasis>
</term>
<listitem>
<simpara>
        All submodules which are cloned will be shallow with a depth of 1.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--</emphasis>[<emphasis>no-</emphasis>]<emphasis>remote-submodules</emphasis>
</term>
<listitem>
<simpara>
        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 <emphasis>--remote</emphasis> to
        <emphasis>git submodule update</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--separate-git-dir=</emphasis><emphasis>&lt;git-dir&gt;</emphasis>
</term>
<listitem>
<simpara>
        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.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--ref-format=</emphasis><emphasis>&lt;ref-format&gt;</emphasis>
</term>
<listitem>
<simpara>
Specify the given ref storage format for the repository. The valid values are:
</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>files</emphasis> for loose files with packed-refs. This is the default.
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>reftable</emphasis> for the reftable format. This format is experimental and its
  internals are subject to change.
</simpara>
</listitem>
</itemizedlist>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>-j</emphasis> <emphasis>&lt;n&gt;</emphasis>
</term>
<term>
<emphasis>--jobs</emphasis> <emphasis>&lt;n&gt;</emphasis>
</term>
<listitem>
<simpara>
        The number of submodules fetched at the same time.
        Defaults to the <emphasis>submodule.fetchJobs</emphasis> option.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>&lt;repository&gt;</emphasis>
</term>
<listitem>
<simpara>
        The (possibly remote) <emphasis>&lt;repository&gt;</emphasis> to clone from.  See the
        <link linkend="git-clone(1)_URLS">GIT URLS</link> section below for more information on specifying
        repositories.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>&lt;directory&gt;</emphasis>
</term>
<listitem>
<simpara>
        The name of a new directory to clone into.  The "humanish"
        part of the source repository is used if no <emphasis>&lt;directory&gt;</emphasis> is
        explicitly given (<emphasis>repo</emphasis> for <emphasis>/path/to/repo.git</emphasis> and <emphasis>foo</emphasis>
        for <emphasis>host.xz:foo/.git</emphasis>).  Cloning into an existing directory
        is only allowed if the directory is empty.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>--bundle-uri=</emphasis><emphasis>&lt;uri&gt;</emphasis>
</term>
<listitem>
<simpara>
        Before fetching from the remote, fetch a bundle from the given
        <emphasis>&lt;uri&gt;</emphasis> and unbundle the data into the local repository. The refs
        in the bundle will be stored under the hidden <emphasis>refs/bundle/*</emphasis>
        namespace. This option is incompatible with <emphasis>--depth</emphasis>,
        <emphasis>--shallow-since</emphasis>, and <emphasis>--shallow-exclude</emphasis>.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-clone(1)__git_urls_anchor_id_git_clone_1__urls_xreflabel_urls">
<title>GIT URLS<anchor id="git-clone(1)_URLS" xreflabel="[URLS]"/></title>
<simpara>In general, URLs contain information about the transport protocol, the
address of the remote server, and the path to the repository.
Depending on the transport protocol, some of this information may be
absent.</simpara>
<simpara>Git supports ssh, git, http, and https protocols (in addition, ftp
and ftps can be used for fetching, but this is inefficient and
deprecated; do not use them).</simpara>
<simpara>The native transport (i.e. git:// URL) does no authentication and
should be used with caution on unsecured networks.</simpara>
<simpara>The following syntaxes may be used with them:</simpara>
<itemizedlist>
<listitem>
<simpara>
<literal>ssh://</literal>&#91;<emphasis>&lt;user&gt;</emphasis><literal>@</literal>&#93;<emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>git://</literal><emphasis>&lt;host&gt;</emphasis>&#91;:<emphasis>&lt;port&gt;</emphasis>&#93;<literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>http</literal>&#91;<literal>s</literal>&#93;<literal>://</literal><emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>ftp</literal>&#91;<literal>s</literal>&#93;<literal>://</literal><emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
</itemizedlist>
<simpara>An alternative scp-like syntax may also be used with the ssh protocol:</simpara>
<itemizedlist>
<listitem>
<simpara>
&#91;<emphasis>&lt;user&gt;</emphasis><literal>@</literal>&#93;<emphasis>&lt;host&gt;</emphasis><literal>:/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
</itemizedlist>
<simpara>This syntax is only recognized if there are no slashes before the
first colon. This helps differentiate a local path that contains a
colon. For example the local path <emphasis>foo:bar</emphasis> could be specified as an
absolute path or <emphasis>./foo:bar</emphasis> to avoid being misinterpreted as an ssh
url.</simpara>
<simpara>The ssh and git protocols additionally support <literal>~</literal><emphasis>&lt;username&gt;</emphasis> expansion:</simpara>
<itemizedlist>
<listitem>
<simpara>
<literal>ssh://</literal>&#91;<emphasis>&lt;user&gt;</emphasis><literal>@</literal>&#93;<emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/~</literal><emphasis>&lt;user&gt;</emphasis><literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>git://</literal><emphasis>&lt;host&gt;</emphasis>&#91;<literal>:</literal><emphasis>&lt;port&gt;</emphasis>&#93;<literal>/~</literal><emphasis>&lt;user&gt;</emphasis><literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
&#91;<emphasis>&lt;user&gt;</emphasis><literal>@</literal>&#93;<emphasis>&lt;host&gt;</emphasis><literal>:~</literal><emphasis>&lt;user&gt;</emphasis><literal>/</literal><emphasis>&lt;path-to-git-repo&gt;</emphasis>
</simpara>
</listitem>
</itemizedlist>
<simpara>For local repositories, also supported by Git natively, the following
syntaxes may be used:</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>/path/to/repo.git/</emphasis>
</simpara>
</listitem>
<listitem>
<simpara>
<literal>file:///path/to/repo.git/</literal>
</simpara>
</listitem>
</itemizedlist>
<simpara>These two syntaxes are mostly equivalent, except the former implies
<emphasis>--local</emphasis> option.</simpara>
<simpara><emphasis>git clone</emphasis>, <emphasis>git fetch</emphasis> and <emphasis>git pull</emphasis>, but not <emphasis>git push</emphasis>, will also
accept a suitable bundle file. See <xref linkend="git-bundle(1)" />.</simpara>
<simpara>When Git doesn't know how to handle a certain transport protocol, it
attempts to use the <emphasis>remote-</emphasis><emphasis>&lt;transport&gt;</emphasis> remote helper, if one
exists. To explicitly request a remote helper, the following syntax
may be used:</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>&lt;transport&gt;</emphasis>::<emphasis>&lt;address&gt;</emphasis>
</simpara>
</listitem>
</itemizedlist>
<simpara>where <emphasis>&lt;address&gt;</emphasis> may be a path, a server and path, or an arbitrary
URL-like string recognized by the specific remote helper being
invoked. See <xref linkend="gitremote-helpers(7)" /> for details.</simpara>
<simpara>If there are a large number of similarly-named remote repositories and
you want to use a different format for them (such that the URLs you
use will be rewritten into URLs that work), you can create a
configuration section of the form:</simpara>
<blockquote>
<literallayout>        [url "<emphasis>&lt;actual-url-base&gt;</emphasis>"]
                insteadOf = <emphasis>&lt;other-url-base&gt;</emphasis></literallayout>
</blockquote>
<simpara>For example, with this:</simpara>
<screen>        [url "git://git.host.xz/"]
                insteadOf = host.xz:/path/to/
                insteadOf = work:</screen>
<simpara>a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".</simpara>
<simpara>If you want to rewrite URLs for push only, you can create a
configuration section of the form:</simpara>
<blockquote>
<literallayout>        [url "<emphasis>&lt;actual-url-base&gt;</emphasis>"]
                pushInsteadOf = <emphasis>&lt;other-url-base&gt;</emphasis></literallayout>
</blockquote>
<simpara>For example, with this:</simpara>
<screen>        [url "ssh://example.org/"]
                pushInsteadOf = git://example.org/</screen>
<simpara>a URL like "git://example.org/path/to/repo.git" will be rewritten to
"ssh://example.org/path/to/repo.git" for pushes, but pulls will still
use the original URL.</simpara>
</simplesect>
<simplesect id="git-clone(1)__examples">
<title>EXAMPLES</title>
<itemizedlist>
<listitem>
<simpara>
Clone from upstream:
</simpara>
<screen>$ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux
$ cd my-linux
$ make</screen>
</listitem>
<listitem>
<simpara>
Make a local clone that borrows from the current directory, without checking things out:
</simpara>
<screen>$ git clone -l -s -n . ../copy
$ cd ../copy
$ git show-branch</screen>
</listitem>
<listitem>
<simpara>
Clone from upstream while borrowing from an existing local directory:
</simpara>
<screen>$ git clone --reference /git/linux.git \
        git://git.kernel.org/pub/scm/.../linux.git \
        my-linux
$ cd my-linux</screen>
</listitem>
<listitem>
<simpara>
Create a bare repository to publish your changes to the public:
</simpara>
<screen>$ git clone --bare -l /home/proj/.git /pub/scm/proj.git</screen>
</listitem>
</itemizedlist>
</simplesect>
<simplesect id="git-clone(1)__configuration">
<title>CONFIGURATION</title>
<simpara>Everything below this line in this section is selectively included
from the <xref linkend="git-config(1)" /> documentation. The content is the same
as what's found there:</simpara>
<variablelist>
<varlistentry>
<term>
<emphasis>init.templateDir</emphasis>
</term>
<listitem>
<simpara>
        Specify the directory from which templates will be copied. (See the "TEMPLATE DIRECTORY" section of <xref linkend="git-init(1)" />.)
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>init.defaultBranch</emphasis>
</term>
<listitem>
<simpara>
        Allows overriding the default branch name e.g. when initializing
        a new repository.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>clone.defaultRemoteName</emphasis>
</term>
<listitem>
<simpara>
        The name of the remote to create when cloning a repository.  Defaults to
        <emphasis>origin</emphasis>.
        It can be overridden by passing the <emphasis>--origin</emphasis> command-line
        option.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>clone.rejectShallow</emphasis>
</term>
<listitem>
<simpara>
        Reject cloning a repository if it is a shallow one; this can be overridden by
        passing the <emphasis>--reject-shallow</emphasis> option on the command line.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis>clone.filterSubmodules</emphasis>
</term>
<listitem>
<simpara>
        If a partial clone filter is provided (see <emphasis>--filter</emphasis> in
        <xref linkend="git-rev-list(1)" />) and <emphasis>--recurse-submodules</emphasis> is used, also apply
        the filter to submodules.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="git-clone(1)__git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
</simplesect>
</sect2>
