Git/Github Clone Private Repository on Ubuntu Server 24.04

author

Dev

. 1 min read

Follow

GitHub is a free platform that provides repository hosting and version control, widely used by web developers to manage and share code. We will guide you to install Git on Ubuntu 24.04, adding and cloning a repository from GitHub to your Ubuntu VPS server.



Preflight

  • Log in as Root: Access your Ubuntu 24.04 server using the root user.

Step 1: Git Installation

The first step is to install Git on your Ubuntu server. Open a terminal and execute the following command:

sudo apt update && sudo apt install git -y

This command will install the latest version of Git on your server. To verify that Git has been installed correctly, run the following command:

git --version

Step 2: Set up a GitHub Account

If you haven't already, create a GitHub account at GitHub.com. It's free! Once you have an account, you'll be able to create a repository (repo) and add your files. To create a new repository, follow these steps:

  1. Log In: Sign in to your GitHub account.
  2. Create a Repository: Click on the "Create a repository" button (or "New repository").
  3. Add Details: You will be directed to a page where you can fill in the details for your new repository, such as the name, description, and visibility settings.

Step 2: Clone Private Repository from Github

Install GitHub CLI on your Ubuntu server and use it to clone a repository

1. Update Your Package List

sudo apt update

2. Install GitHub CLI

You have two main options for installing GitHub CLI: using snap or apt. Choose the method you prefer.

sudo snap install gh
sudo apt install gh

3. Verify Installation

To check if GitHub CLI is installed correctly, run:

gh --version

You should see output indicating the installed version of GitHub CLI.

4. Authenticate GitHub CLI

Authenticate your GitHub account with the CLI. This step is necessary to interact with your repositories:

gh auth login

Follow the prompts to complete the authentication process. In this process you will get one-time code. First copy your one-time code and paste it in https://github.com/login/device ( manual )

5. Clone Your Repository

Now, you can clone your repository using the gh command:

gh repo clone x-dev15/private

This command will clone the private repository from the x-dev15 GitHub account into your current directory.

More Stories from Developerbook

How to setup Erlang on windows environment

How to setup Erlang on windows environment

How to configure eclipse plug-in for erlang

How to configure eclipse plug-in for erlang

Isolation concept for transaction

Isolation concept for transaction

Alloy ui basic tutorial

Alloy ui basic tutorial

First web service using eclipse and java

First web service using eclipse and java