Skip to content

Ubuntu Lightsail: Cloning private GitHub repository using a personal access token (PAT)

0

Took help of ChatGPT: When cloning your private GitHub repository using a personal access token (PAT), you need to replace the placeholders in the command with your actual GitHub username and repository name. Here's the breakdown of the placeholders:

<your-username>: Your GitHub username. <your-PAT>: Your personal access token. <your-repository>: The name of your repository. For example, if your GitHub username is johndoe, your personal access token is ghp_abcdef1234567890, and your repository name is my-flask-app, you would enter:

git clone https://johndoe:ghp_abcdef1234567890@github.com/johndoe/my-flask-app.git
cd my-flask-app

For my case then, I have this code:

git clone https://SplendidDigital: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@github.com/SplendidDigital/code50/23315992.git
cd code50/23315992

Not sure what I am missing as showing:

Obifze08XiPl@github.com/SplendidDigital/code50/23315992.git
Cloning into '23315992'...
remote: Not Found
fatal: repository 'https://github.com/SplendidDigital/code50/23315992.git/' not found
ubuntu@ip-172-26-0-248:~$ 
ubuntu@ip-172-26-0-248:~$ cd code50/23315992
-bash: cd: code50/23315992: No such file or directory
ubuntu@ip-172-26-0-248:~$ 

Enter image description here

Enter image description here

asked 2 years ago723 views

4 Answers
1
Accepted Answer

Paste the "git clone" command below as is.

git clone https://SplendidDigital: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@github.com/code50/23315992.git

In my environment, I can successfully clone as shown below.

git clone https://SplendidDigital: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@github.com/code50/23315992.git
Cloning into '23315992'...
remote: Enumerating objects: 21274, done.
remote: Counting objects: 100% (4465/4465), done.
remote: Compressing objects: 100% (1917/1917), done.
remote: Total 21274 (delta 2310), reused 4448 (delta 2294), pack-reused 16809
Receiving objects: 100% (21274/21274), 65.65 MiB | 14.69 MiB/s, done.
Resolving deltas: 100% (10108/10108), done.
Updating files: 100% (1268/1268), done.

ls -la 23315992/
合計 16
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:29 .
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 ..
-rw-r--r-- 1 riku_matsui riku_matsui 9230  7月 18 22:28 .devcontainer.json
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:29 .git
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 .vscode
-rw-r--r-- 1 riku_matsui riku_matsui  123  7月 18 22:28 addresses.c
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 birthdays
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 bottomup
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 caesar
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 cash
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 credit
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 cs50w1
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 dna
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 fiftyville
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 filter-less
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 finance
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 flaskprac
-rw-r--r-- 1 riku_matsui riku_matsui    0  7月 18 22:28 hee.c
-rw-r--r-- 1 riku_matsui riku_matsui   64  7月 18 22:28 hello.c
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 homepage
-rw-r--r-- 1 riku_matsui riku_matsui  970  7月 18 22:28 image.c
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 inheritance
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 mario-less
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 mario-more
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 me
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 microblog
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 movies
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 plurality
-rw-r--r-- 1 riku_matsui riku_matsui   87  7月 18 22:28 plurality.c
-rw-r--r-- 1 riku_matsui riku_matsui  605  7月 18 22:28 practice.c
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 readability
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 recover
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 reverse
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 runoff
-rw-r--r-- 1 riku_matsui riku_matsui    0  7月 18 22:28 runoff.c
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 scrabble
-rw-r--r-- 1 riku_matsui riku_matsui  274  7月 18 22:28 scrabble.c
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 sentimental-cash
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 sentimental-credit
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 sentimental-hello
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 sentimental-readability
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 smiley
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 songs
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 sort
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 speller
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 sql
-rw-r--r-- 1 riku_matsui riku_matsui    4  7月 18 22:28 style.html
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 substitution
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 tideman
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 trie
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 trivia
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:28 venv
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:29 volume
-rw-r--r-- 1 riku_matsui riku_matsui   61  7月 18 22:29 week1.c
drwxr-xr-x 1 riku_matsui riku_matsui 4096  7月 18 22:29 world
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

AWS
EXPERT

reviewed 2 years ago

1

Hello.

Please try using the URL below.
"SplendidDigital/" in the URL is not required.
Also, be careful not to expose your GitHub credentials publicly.

git clone https://SplendidDigital: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@github.com/code50/23315992.git
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Thanks! Tried once again but getting: URL using bad/illegal format or missing URL

0
Last login: Thu Jul 18 12:27:57 2024 from 54.239.98.242
ubuntu@ip-172-26-0-248:~$ git clone https://SplendidDigital:ghp_B5SwwlldsfkbJVS5qbMqFSVK
Obifze08XiPl
Cloning into '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'...
fatal: unable to access 'https://SplendidDigital:ghp_B5SwwlldsfkbJVS5qbMqFSVKObifze08XiP
l/': URL using bad/illegal format or missing URL
ubuntu@ip-172-26-0-248:~$ 

answered 2 years ago

0

Hello,

To clone a private GitHub repository using a personal access token (PAT), use the following format:

$ git clone https://<your-username>:<your-PAT>@github.com/<your-username>/<your-repository>.git

For your specific case, use:

$ git clone https://SplendidDigital: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@github.com/SplendidDigital/code50.git

$ cd code50

If you still encounter issues, double-check the repository URL on GitHub to ensure it matches exactly.

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.