How to clone a Git repository

Basic usage

The first thing you usually do when starting working on a project is cloning a git repository (or repo for short). The usual command is

git clone

This will clone the repository into a folder named MyProject and check out the master branch.

If you would like to clone just a specific branch, you can use the following command instead (but note that this would clone only this one branch; the other branches will not be immediately available in your local repository):

git clone --branch some-branch

If the repository you're cloning contains submodules, you might want to clone them as well, in which case use the following command:

git clone --recursive

Written on December 31, 2020