LinuxCommandLibrary

git-clone

TLDR

Clone a repository

$ git clone [https://github.com/owner/repo.git]
copy
Clone to specific directory
$ git clone [url] [directory]
copy
Shallow clone
$ git clone --depth 1 [url]
copy
Clone specific branch
$ git clone --branch [branch] [url]
copy
Clone with submodules
$ git clone --recursive [url]
copy

SYNOPSIS

git clone [options] repository [directory]

DESCRIPTION

git clone creates a copy of a remote repository. It downloads all branches, tags, and history, setting up remote tracking for the origin.
The command supports various protocols including HTTPS, SSH, and git://. Shallow clones reduce download size for large repositories. Bare clones create server-side repositories.
git clone is the standard way to obtain a copy of any git repository.

PARAMETERS

REPOSITORY

Repository URL or path.
DIRECTORY
Target directory name.
--depth N
Create shallow clone with N commits.
--branch BRANCH
Clone specific branch.
--recursive
Initialize submodules.
--bare
Create bare repository.
--mirror
Create mirror clone.
--single-branch
Clone only one branch.
--help
Display help information.

CAVEATS

Large repos can take time. Shallow clones limit some operations. SSH requires key setup.

HISTORY

git clone is a fundamental Git command from its initial release, providing distributed repository copying that defines git's model.

SEE ALSO

git(1), git-fetch(1), git-remote(1)

Copied to clipboard