СHRISTMAS
WHEEL OF FORTUNE

Tap the button and win a guaranteed prize right now!

By registering, you are signing up to receiving e-mails.
JT
August 19 2024
Updated August 19 2024

How to clone repository from GitHub?

Git

The repository version control system was a revolutionary step in team development, documentation, and project management. The ability to maintain public repositories has also given many users access to software developed by the community. One of the most popular repository hubs is GitHub, in this article we will look at ways to work with it!

What is Git and GitHub?

Git is a repository version control system that provides a means of managing collections stored on a server with the ability to collaboratively maintain a project.

GitHub is a platform based on the Git system with mechanisms for organising the software development cycle and managing services. It is managed through a web panel, and it is possible to differentiate access to the repository: for yourself, team, and public use.

There are several variants of Git/Github repository architecture:

  • Distributed, implemented as a collection of nodes with the ability to publicly access the resource;
  • Server-based, implemented by a single node, mainly in the corporate segment;
  • Local, for working with repositories on a user's device, as a kind of workspace for projects.

It usually works as follows: the client initialises a repository in a working folder using the git utility:

git init /path

The user then adds the necessary files to it to work on, logging changes to the working directory, or Working Tree, using the command:

git add .

After that, the user creates a snapshot of the working directory or commit and saves the files for further transfer to the repository, where the Commit aggregate is stored. It is possible to send data to local repositories with a single command:

git push origin main

Or to a remote repository such as GitHub or GitLab, but how do you do that? And how do you download a repository from GitHub to your device? Let's explore these questions below.

How do I download a repository to GitHub?

First, let's find the desired project on the official website and go to the Code tab:

Download options
Screenshot №1 — Download options

There are several options for cloning or fully downloading the repository:

  • HTTPS - download is possible via ZIP archive via the button below or via the git clone <URL> command;
  • SSH - download is via tunnel with public key authentication on the server;
  • GitHub CLI - a utility for GitHub, in the form of a client with slightly extended functionality.

Let's consider the first two options of downloading via the git utility using HTTPS and SSH protocols. For the first option, go to a terminal and type:

git clone {URL}

Instead of the URL, enter your repository link and wait for the latest version to download. After that a working directory similar to the repository name will be created:

Clone from HTTPS
Screenshot №2 — Clone from HTTPS

Via SSH the download scheme is a bit different, on the client device view your SSH public keys:

For Linux classically located in the .ssh folder, the file name may vary:

cat /home/your-login/.ssh/id_rsa.pub

For Windows, the command is as follows:

cat C:/home/your-login/.ssh/id_rsa.pub

The key should take the following form, copy your key:

ssh- rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCutHsqJMHaBHLMpl6DkH/x/0H/fwPT687X11omrzqNGJNyehDSw4EyY9kfcz6Y4LG/JgTLuBGfZpE9TCvudvAgo6BV9jM9Hsqw/G9PlB99h9K14B/gtSCdzmT5cxFmTEcbrSbtdQukNFJL1BRab/ayJ0CkMiID7QHac0WRp2gN0fo4ozG4LpHcLyXxn4J5MsfJxvSvo3T8gFtEjKPp8KE0Q6YVEAQ7fC97D+4B+V7hd3wM4WZvlBh2RtWdZcaomLis5Pa/wzcH8WsibQ0w5Rw5+Xrw4pnUjbtnEr4YHn3Rx0T1tBg/HudPrqZ4se0MW8o7bZXYIrDnyIwQ8lyTG8IQMEqyh4+XssEAKX1D4UZpG93c7pXylDwUhJ0LEeQuzfnLQmeSFML7DILQh4CY8BG/L1Vgbo2PNyiVWYLalJoTjLna2LpooTjgjH44t2rHiULDsCJBGq6Js1Bjk3LiqtIawYjdxEcv4Vgu4zPAgvnvFmkY4v8HFph578tgoSgoZPk= gg@DESKTOP- GFERDSA

If you don't have a key, create one, using the command:

ssh-keygen

Then repeat the above steps and copy the key! After that go to the GitHub site and go to user settings via the avatar on the top right. Select SSH and GPG keys on the left:

New SSH Keys
Screenshot №3 — New SSH Keys

Click on the New SSH key button and type in the copied key, as well as enter a short name for it:

Enter your key
Screenshot №4 — Enter your key

After clicking Add SSH key and confirm the changes with your account password, the key should be added as an authentication method:

New authentification way
Screenshot №5 — New authentification way

Great! Now we can go to the client terminal and download the repository with the usual command:

Result of cloning
Screenshot №6 — Result of cloning

The client authenticated to the server with a private key and identified itself with a public key, which allowed access to the repository.

All actions can be performed on powerful cloud servers. Serverspace provides isolated VPS / VDS servers for common and virtualize usage.

Create Server
Screenshot №7 — Create Server

It will take some time to deploy server capacity. After that you can connect in any of the convenient ways.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.