Cloning is essentially the process of downloading an existing repository hosted on a remote server to your own computer.
In this artcile, We will see how to clone a remote repository hosted on GitHub.
Finding the remote URL for your repository is fairly straight forward on GitHub. All you need to do is head on over to the overview page for your project.
As we have seen in our other article, there are two protocols you can use when working with Git; HTTPS and SSH.
Toggle to your preferred protocol by clicking the “Use SSH” or “Use HTTPS” links, then click the small button next to the URL to copy it to your clipboard.
Once you’ve got the repository URL, open up the
command line and navigate to the directory where you want the code to live. I have a folder called
WebProjects located inside my home directory where I keep all the code I work on.
When you’re ready to clone type the following command, making sure to replace the URL with the one you just copied from GitHub:
git clone firstname.lastname@example.org:bhavik/laravel-demo.git
If successful, the output will look a little something like this:
Cloning into 'laravel-demo'...
remote: Enumerating objects: 227, done.
remote: Counting objects: 100% (227/227), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 227 (delta 2), reused 227 (delta 2), pack-reused 0
Receiving objects: 100% (227/227), 44.39 KiB | 845.00 KiB/s, done.
Resolving deltas: 100% (2/2), done.
By default, Git will create a folder with the same name as the repository, however you can change this by providing an extra argument to the git clone command.
For example, if you’d rather clone the project into a
laravel-site, you would enter the
git clone email@example.com:bhavik/laravel-demo.git laravel-site