There are three ways you can clone a git repository – HTTPS, SSH, and GitHub CLI. Visit your GitHub account, visit your repo page and check for the green button in the top right portion of the page.
The dropdown has links for each of these options. Let us call them as <https link>, <ssh link> and <GitHub CLI command>.
Before issuing the command, the setup looks as shown. We would be present in a directory where we want to download the repo.
$ ls $
Issue git clone <https link> and download the repo onto your system.
$ git clone https://github.com/codeversionmaster/repoone.git Cloning into 'repoone'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), 596 bytes | 42.00 KiB/s, done. $ ls repoone $ ls repoone/ README.md
For ssh method, first create a key in your terminal.
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/paperspace/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/paperspace/.ssh/id_rsa Your public key has been saved in /home/paperspace/.ssh/id_rsa.pub The key fingerprint is: SHA256:IA14KDMfbuwdR7b0OaY2I3qJfqdODN8nnHrsBfgP2Rc ... $ ls .ssh/ authorized_keys id_rsa id_rsa.pub
Copy key text from .ssh/id_rsa.pub. There are two ways now to paste it.
~$ cat .ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDeLzW/m4gGbf........
Method 1: Paste it into the ssh keys portion of your GitHub account for access across all the repositories in your account. Visit your GitHub account, click on “SSH and GPG keys” in the left sidebar and add the key. You can directly visit this page by visiting https://github.com/settings/ssh/new.
Method 2: Visit your repository page. Click on “Deploy keys” in the left sidebar. Add the key here. You can directly reach the URL which is of this format –https://github.com/codeversionmaster/repoone/settings/keys.
Use git clone <ssh link>.
$ git clone email@example.com:codeversionmaster/repoone.git Cloning into 'repoone'... Warning: Permanently added the ECDSA host key for IP address '184.108.40.206' to the list of known hosts. remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Receiving objects: 100% (3/3), done. $ ls repoone
Install gh. Ex: on an ubuntu machine, issue the command as shown.
$ sudo snap install gh gh 2.6.0-15-g1a10fd5a from Casper (casper-dcl) installed
Do the auth step.
$ gh auth login
Clone the repo using <GitHub CLI command>
$ gh repo clone codeversionmaster/repoone