Previous class
Git Clone Private Repo
To clone your private repository to another server, you'll need to use a method that allows authentication. Here are the two main approaches:
1. SSH (Recommended):
This is the most secure and convenient way to clone a private repository.
Prerequisites:
- SSH Key Pair on the New Server: Generate an SSH key pair on the server where you want to clone the repository (if it doesn't have one already). You can use
ssh-keygen
for this. - Public Key Added to GitHub: Make sure the public key from the new server is added to the list of "SSH and GPG keys" in your GitHub account settings.
Steps:
- Get the SSH URL:
- Go to your GitHub repository.
Click the "Code" button and select the "SSH" tab to copy the SSH URL. It should look like this:git@github.com:cr0atz/flast-ai-v5.1.git
- Clone the Repository:
- On the new server, open a terminal and run:Bash
git clone git@github.com:cr0atz/flast-ai-v5.1.git
- content_copy
- This will clone the repository using SSH authentication.
2. Personal Access Token (PAT):
This method is an alternative if you don't want to use SSH keys.
Prerequisites:
- Personal Access Token (PAT): Generate a PAT in your GitHub account settings with the "repo" scope.
Steps:
- Clone the Repository:On the new server, run the following command, replacing
<your_pat>
with your actual PAT:Bash
git clone https://<your_pat>@github.com/cr0atz/flast-ai-v5.1.git
- content_copy
- This will prompt you for your GitHub username (which you can enter). Git will use the PAT you've included in the URL for authentication.
Important Considerations:
- HTTPS vs. SSH: The SSH method uses the
git@github.com
URL, while the PAT method uses thehttps://github.com
URL. - Security: SSH keys are generally more secure than embedding your PAT directly in the URL.
- 2FA: If you have two-factor authentication (2FA) enabled on GitHub, you'll be prompted for a 2FA code during the cloning process if you use the PAT method.
Additional Tips:
- Virtual Environments: If your project uses a virtual environment, remember to create and activate a new virtual environment on the new server before installing dependencies.
- Troubleshooting: If you encounter permission errors, ensure that the user running the
git clone
command has the necessary permissions to create the repository directory and files on the new server.
Let me know if you have any other questions!
Next class