Clone a Private Github Repo with a Personal Access Token

In this short post I will demonstrate how to clone a private github repository with a personal access token.

From github.com/settings/tokens select the scopes:

  • repo:status
  • repo_deployment
  • public_repo
  • repo:invite
  • security_events

You will receive a token which you need to keep in a safe place.

Set your token in your git clone string:

$ git clone https://${TOKEN}:x-oauth-basic@github.com/MyUser/MyRepo.git

Resources:

Thanks for reading, if you enjoy my content feel free to follow me on Twitter at @ruanbekker and subscribe to my newsletter.