How to clone a Github repo

Problem

You need to learn how to clone a Github repository to start your first job? Your client wants you to clone their working repo and you need to learn how? Let me help you.

Solution

To clone a repository with Git you need your git client and the url of the repository. Normally you will clone the repo by https.

Once you have the url to the repository (e.g. https://github.com/mirumee/saleor), you can clone the repository. Simply attach an .git at the end of it (e.g. https://github.com/mirumee/saleor.git)

GUI Client (Sourcetree)

As a graphical git client I will use Sourcetree in this Example.

How to clone a Github repo Sourcetree select new
Select New
How to clone a Github repo Sourcetree select clone from url
Select Clone from URL
How to clone a Github repo Sourcetree select new. Enter Source Url
Enter Source Url
How to clone a Github repo Sourcetree Prepared Dialog
Prepared Dialog. Make sure the local path is correct for you

Select Clone and git clones the repo.

How to clone a Github repo Sourcetree Git cloning in progress
Cloning in progress

Once the cloning process process finished it looks like this:

Github how to download clone public repository Downloading (cloning) from Github finished
Downloading (cloning) from Github finished

Git cli client

I use a terminal with the Git client on Mac OS for this example:

How to clone a Github repo git cli Navigate to the target directory
Navigate to the target directory

How to clone a Github repo git cli Execute git clone $url
Execute git clone $url

How to clone a Github repo Git cli cloning repository in progress
Git cli cloning repository in progress

How to clone a Github repo Git cli cloning finished
Git cli cloning finished

Explanation

In both cases have you downloaded (cloned) the public Github repository successfully. Inside the directory (in this example saleor) you find code of the lastest master version.

git clone $url + “.git” is how you clone a public repository from Github normally.

In Sourcetree you use clone from url and also use $url + “.git” as the url to start the cloning process.

Other graphical git clients are similar to Sourcetree and you shouldn´t have any problems finding the option in them too.

Github offers also the options to clone a repository via SSH. For a developer it is more unusual to use this option. It’s more likely to be used on a server when you want to automate processes.

Background

Git as a source code versioning system has widespread usage today. Especially thanks to its decentralized structure it is easy to use. And many place offer hosting for it.

Github is for a long time already the choice for open source projects where hundreds or thousands of developers are working alone or together on projects. Companies also use it more and more.

Which makes you more valuable when you know how to use git. How to clone a Github repository is the first step on that road.

Let me know when it helped.

Best,

Frank

Sources:

https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository

Leave a Reply