Git Getting started with Git Clone a repository

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The 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 protected]/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. MyFolder:

git clone https://github.com/username/projectname.git MyFolder

Or to clone in the current directory:

git clone https://github.com/username/projectname.git .

Note:

  1. When cloning to a specified directory, the directory must be empty or non-existent.

  2. You can also use the ssh version of the command:

    git clone [email protected]:username/projectname.git
    

The https version and the ssh version are equivalent. However, some hosting services such as GitHub recommend that you use https rather than ssh.



Got any Git Question?