git clone command is used to copy an existing Git repository from a server to the local machine.
For example, to clone a GitHub project:
cd <path where you'd like the clone to create a directory> git clone https://github.com/username/projectname.git
To clone a BitBucket project:
cd <path where you'd like the clone to create a directory> git clone https://email@example.com/username/projectname.git
This creates a directory called
projectname on the local machine, containing all the files in the remote Git repository. This includes source files for the project, as well as a
.git sub-directory which contains the entire history and configuration for the project.
To specify a different name of the directory, e.g.
git clone https://github.com/username/projectname.git MyFolder
Or to clone in the current directory:
git clone https://github.com/username/projectname.git .
When cloning to a specified directory, the directory must be empty or non-existent.
You can also use the
ssh version of the command:
git clone firstname.lastname@example.org:username/projectname.git
https version and the
ssh version are equivalent. However, some hosting services such as GitHub recommend that you use
https rather than