# info > GIT-CLONE

---
type: CommandReference
command: git-clone
mode: man
section: 1
source: man-pages
---

## Quick Reference
- `git clone https://github.com/user/repo.git` — Clone a repository into a new directory named `repo`
- `git clone -b develop https://github.com/user/repo.git` — Clone and checkout the `develop` branch
- `git clone --depth 1 https://github.com/user/repo.git` — Shallow clone with only the latest commit
- `git clone --bare https://github.com/user/repo.git` — Create a bare repository (no working tree)
- `git clone --mirror https://github.com/user/repo.git` — Mirror all refs for a full backup
- `git clone --recurse-submodules https://github.com/user/repo.git` — Clone and initialize submodules
- `git clone --reference /path/to/local/repo https://github.com/user/repo.git` — Borrow objects from a local repository to reduce network transfer
- `git clone -l -s -n . ../copy` — Local clone that shares objects without checking out

## Name
git-clone - Clone a repository into a new directory

## Synopsis
`git clone [<options>] <repository> [<directory>]`

## Options

### Local cloning
- `-l, --local` — When the source is a local path, clone by copying HEAD, objects, and refs, using hardlinks for objects when possible. This is the default for local paths; `--no-local` forces the normal Git transport.
- `--no-hardlinks` — Copy object files instead of hardlinking when cloning from a local filesystem.
- `-s, --shared` — Share objects with the source repository via `.git/objects/info/alternates`. **Note:** can lead to corruption if source objects are garbage-collected. Use `git repack -a` to break the dependency.
- `--reference <repository>` — Use the given local repository as an alternate to reduce network transfer. `--reference-if-able` version skips non‑existing directories with a warning.
- `--dissociate` — After cloning, copy borrowed objects locally and stop using the reference repository.

### Output control
- `-q, --quiet` — Suppress progress output to stderr.
- `-v, --verbose` — Verbose output; does not affect progress reporting.
- `--progress` — Force progress status to stderr even when not attached to a terminal.

### Repository type
- `-n, --no-checkout` — Do not check out HEAD after cloning.
- `--bare` — Create a bare repository (no working tree). Implies `--no-checkout`. Remote branches are copied directly to local branches, no `refs/remotes/origin/` mapping.
- `--mirror` — Set up a mirror (implies `--bare`). All refs are mapped and a refspec is configured so that `git remote update` overwrites them.
- `--sparse` — Initialize the sparse-checkout file to start with only root files. The working directory can be expanded later.

### Branch and history
- `-b <name>, --branch <name>` — Check out the given branch (or tag, detaching HEAD) instead of the remote’s HEAD.
- `--depth <depth>` — Create a shallow clone with only the specified number of commits. Implies `--single-branch` unless `--no-single-branch` is given.
- `--shallow-since=<date>` — Shallow clone with history after the given date.
- `--shallow-exclude=<revision>` — Shallow clone excluding commits reachable from the specified ref. Repeatable.
- `--[no-]single-branch` — Clone only the history of a single branch. Further fetches will only update that branch’s remote‑tracking ref.
- `--no-tags` — Do not clone tags and set `remote.<name>.tagOpt=--no-tags` so future fetches ignore tags.
- `--filter=<filter-spec>` — Partial clone; request only a subset of objects (e.g., `blob:none` or `blob:limit=<size>`). See [git-rev-list(1)](http://localhost/phpMan.php/man/git-rev-list/1/markdown).
- `--[no-]reject-shallow` — Fail if the source is a shallow repository (configurable with `clone.rejectShallow`).

### Submodules
- `--recurse-submodules[=<pathspec>]` — After cloning, initialize and clone submodules matching the pathspec (all if none given). Ignored with `--no-checkout`, `--bare`, or `--mirror`.
- `--[no-]shallow-submodules` — Clone submodules with a depth of 1.
- `--[no-]remote-submodules` — Use the submodule’s remote‑tracking branch (like `--remote` in `git submodule update`).
- `-j <n>, --jobs <n>` — Number of submodules fetched in parallel (defaults to `submodule.fetchJobs`).

### Configuration and misc
- `-o <name>, --origin <name>` — Use `<name>` as the remote name instead of `origin`.
- `-u <upload-pack>, --upload-pack <upload-pack>` — Non‑default path for `git-upload-pack` on the remote (ssh only).
- `--template=<template_directory>` — Specify the template directory (see [git-init(1)](http://localhost/phpMan.php/man/git-init/1/markdown)).
- `-c <key>=<value>, --config <key>=<value>` — Set a configuration variable in the new repository (takes effect immediately after init). Some variables (e.g., `remote.<name>.mirror`, `remote.<name>.tagOpt`) do not apply until after the initial fetch; use `--mirror` or `--no-tags` instead.
- `--server-option=<option>` — Transmit a string to the server (protocol v2). Pass multiple times for multiple options.
- `--separate-git-dir=<git dir>` — Place the repository’s Git directory at the given path, leaving a symlink in the working tree.

## Examples

Clone from upstream:
shell
$ 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 out:
shell
$ git clone -l -s -n . ../copy
$ cd ../copy
$ git show-branch
Clone from upstream while borrowing from an existing local directory:
shell
$ 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:
shell
$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
## GIT URLS

Git supports ssh, git, http, https, and (deprecated) ftp/ftps protocols. The native git:// protocol offers no authentication.

Common URL syntaxes:
- `ssh://[user@]host.xz[:port]/path/to/repo.git/`
- `git://host.xz[:port]/path/to/repo.git/`
- `http[s]://host.xz[:port]/path/to/repo.git/`
- `[user@]host.xz:path/to/repo.git/` (scp‑like, ssh only)

Local repositories can be specified as `/path/to/repo.git/` (implies `--local`) or `file:///path/to/repo.git/`. Both `ssh` and `git` protocols support `~username` expansion.

Git also accepts bundle files and can use remote helpers (`<transport>::<address>`). See [git-bundle(1)](http://localhost/phpMan.php/man/git-bundle/1/markdown) and [gitremote-helpers(7)](http://localhost/phpMan.php/man/gitremote-helpers/7/markdown).

URL rewriting can be configured via `[url "<actual base>"]` sections with `insteadOf` (for all operations) or `pushInsteadOf` (for pushes only). Example:
ini
[url "git://git.host.xz/"]
    insteadOf = host.xz:/path/to/
    insteadOf = work:
## See Also
[git(1)](http://localhost/phpMan.php/man/git/1/markdown), [git-fetch(1)](http://localhost/phpMan.php/man/git-fetch/1/markdown), [git-pull(1)](http://localhost/phpMan.php/man/git-pull/1/markdown), [git-init(1)](http://localhost/phpMan.php/man/git-init/1/markdown), [git-bundle(1)](http://localhost/phpMan.php/man/git-bundle/1/markdown), [gitremote-helpers(7)](http://localhost/phpMan.php/man/gitremote-helpers/7/markdown), [git-config(1)](http://localhost/phpMan.php/man/git-config/1/markdown), [git-rev-list(1)](http://localhost/phpMan.php/man/git-rev-list/1/markdown)