How to clone a private repository in github into the remote server

发布时间:2023年12月18日

Cloning a Private Repository into a CentOS Server

This tutorial outlines the steps to clone a private Git repository into a CentOS server.

Prerequisites

  • A CentOS server
  • Access to a private repository (e.g., on GitHub)

Steps

1. Install Git on CentOS

First, update your package manager and install Git:

sudo yum update
sudo yum install git

2. Set Up SSH Keys (for SSH authentication)

If using SSH for authentication, set up SSH keys:

Generate a New SSH Key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Follow the prompts
Add Your SSH Key to the SSH-Agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
Copy the SSH Key
cat ~/.ssh/id_rsa.pub
# Copy the output

3. Add the SSH Key to Your GitHub Account

Steps
  1. Log into your GitHub account.
  2. Go to Settings > Deploy keys.
  3. Click on Add Deploy key.
  4. Paste your copied SSH key and add a descriptive title.
  5. Click Add SSH key.

4. Clone the Repository

Navigate to the desired directory and use the git clone command:

git clone git@github.com:username/repository.git
# Replace with your repository's SSH URL

For HTTPS, replace the URL accordingly. You might be prompted to enter your credentials if it’s a private repository.

Conclusion

After these steps, you should have the private repository cloned into your CentOS server. You can now navigate to the repository’s directory and start working on it.

文章来源:https://blog.csdn.net/weixin_38396940/article/details/135051618
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。