Clone Private GitHub Repo
git clone https://<github-username>:<PAT>@github.com/<your-repository>.git
Create GitHub Personal Access Token(PAT)
- In GitHub, go to
Settings
β Developer Settings
β Personal access tokens
.
- Click
Generate new token
and assign the token a name.
- Grant the token privilege to the repo group.
- Copy the token to a secure location. You wonβt be able to view the token again.
- 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