Clone Private GitHub Repo

git clone https://<github-username>:<PAT>@github.com/<your-repository>.git
Create GitHub Personal Access Token(PAT)
  1. In GitHub, go to Settings β‡’ Developer Settings β‡’ Personal access tokens.
  2. Click Generate new token and assign the token a name.
  3. Grant the token privilege to the repo group.
  4. Copy the token to a secure location. You won’t be able to view the token again.
  5. At the bottom of the page, click Generate Token.

Make a Private Clone of a Public Repo

# Create an empty private repo
 
# Clone the upstream repo
git clone --bare https://github.com/<upstream-user>/<upstream-repo>.git
cd <upstream-repo>.git
 
# Push the content to the empty repo
git push --mirror https://github.com/<user>/<repo>
cd ..
rm -rf <upstream-repo>.git/
 
# Add upstream
git clone https://github.com/<user>/<repo>.git
cd <repo>
git remote add upstream https://github.com/<upstream-user>/<upstream-repo>.git