Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Clone a repository

Summary

To clone a remote repository, enter the following command in your terminal (replace the URL with the URL of the repo you want to clone):

git clone https://github.com/username/repo-name.git

Details

If you’ve created a brand new repo on GitHub and want to start working on it on your local computer, you can use the git clone command from above to clone it to your computer. From there, you can start adding files, folders, and code to it.

Another situation where you might use the git clone command is if you have a remote repo with code already in it and want to clone it to your local computer. This might happen if you started the project on one computer and need to clone it to a new computer, or if you’ve been invited to collaborate with someone on their repo.

If you want to connect a brand new repo on GitHub to a local project on your computer, you should add the remote repo to your project instead.

If the above command is successful, you should see something similar to the following print out in your terminal:

Cloning into 'repo-name'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 17 (delta 3), reused 15 (delta 1), pack-reused 0
Unpacking objects: 100% (17/17), done.

You can then use the ls command to verify that the folder was created.

References

Getting a Git Repository from the Git Pro book (see the section called Cloning a Remote Repository)

Back to: GitHub Reference