How to clone a GitHub repository
Last updated:
When cloning a GitHub repository you can choose either https or ssh. I will explain both methods:
Alt 1: Clone a GitHub repository with https
- Login to GitHub and open the repo you want to clone
- Press the “Code” button and choose HTTPS
- Copy the URL
- Open the terminal and navigate to the folder where you want the cloned repo
- Write “git clone” and paste the URL you copied
git clone https://github.com/username/reponame.git
Alt 2: Clone a GitHub repository using SSH
In order to use SSH you first have to exchange keys. If you haven't already, take a look at this post:
- Login to GitHub and open the repo you want to clone
- Press the “Code” button and choose SSH
- Copy the URL
- Open the terminal and navigate to the folder where you want the cloned repo
- Write “git clone” and paste the URL you copied
git clone git@github.com:username/reponame.git
You may get this warning:
The authenticity of host 'github.com (140.82.121.3)' can't be established.
RSA key fingerprint is ....
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Write yes and press enter.
List files to see if the repo was successfully added; "ls" on Linux, "dir" on Windows.