Git Clone
The git clone
is a Git command-line utility used to clone or copy a target repository.
The copy which is created by the git clone
command is a working Git repository with the full history of the cloned repository.
Git supports several transport protocols to connect to a remote Git repository GIT, SSH, HTTPS.
Git clone repository
git clone https://github.com/username/the-repo-you-want-to-clone.git
Clone a remote repository that already exists in the current local folder. The cloned folder will include all of the files, branches, and commits.
Cloning to a specific folder
git clone https://github.com/username/the-repo-you-want-to-clone.git "your local folder."
Clone a remote repository to a specific directory without switching to that particular directory.
Cloning a specific branch
git clone --branch -b master https://github.com/username/the-repo-you-want-to-clone.git
Clone only a particular branch from a repository. In the example above, we clone just the branch master.
Another abbreviation of --branch [url-repo]
is -b [url-repo]
.
Shallow clone
git clone -depth=1 https://github.com/username/the-repo-you-want-to-clone.git
Clone the remote repository but only clone the history of commits specified by the option depth=. In this example, it will clone just the last revisions of the repository.