Phil for Humanity Phil for Humanity
A Guide for the Survival of Humankind and Helping the World, Society, and Yourself.

Git Clone

The command to download (not update) a Git repository is:

git clone URL

The URL (also known as HTTP or web address) is the address of where the remote repository is located. Your Git administrator should give you this URL address. Additionally, you must have read access to clone a local copy of the repository.

By default, a new repository (directory) will be created using the repository's name as the directory name into your current directory. So, if you want to download a second copy of the same repository into the same root directory, then you will need to specify a new unique directory name by running this command:


Having more than one copy of a repository is useful when working on different branches at the same time, and you do not want to spend any time backing up or stashing your data before switching between branches. It is much easier to just switch directories or cloned repositories.

Another good git clone option is the depth argument that will restrict how many revisions or history of each file that will be downloaded to decrease the amount of data transferred and time when cloning.

git clone --depth DEPTH_# URL

For instance, a depth of "1" is ideal for build servers for faster performance, especially since the depth argument does not allow pushing changes back to the remote repository or even pulling new changes from the remote repository.

by Phil for Humanity
on 11/06/2012

Related Articles
 » Git Repository Permissions
 » Git Configuration: Reading and Setting
 » Git Changes