DEV Community

Super Kai (Kazuya Ito)
Super Kai (Kazuya Ito)

Posted on

Clone a private repository with PAT from Github

Buy Me a Coffee

*My post explains how to clone a private repository with FGPAT(Fine-Grained Personal Access Token) from Github.

With PAT(Personal Access Token), you can clone a private repository from your account and you can also clone a private repository from your organization if you're its owner or member:
*Memos:

  • You need to generate a PAT and add it to the command below. *Organization doesn't have PAT or FGPAT generator.
  • A PAT cannot select permissions more precisely(finely) than FGPAT.
  • pat is PAT.
  • fgpat is FGPAT.
git clone https://<pat or fgpat>@github.com/<your account or organization>/<repo>.git
Enter fullscreen mode Exit fullscreen mode

<How to generate a FGPAT from your account>

  1. Go to Settings:
    Image description

  2. Go to Developer settings:
    Image description

  3. Press Generate new token (classic) from Personal access tokens/Tokens(classic)/Generate new token:
    Image description

  4. Fill Note, then check repo. *If repo is not checked, you cannot clone a private repository:
    Image description

  5. Press Generate token:
    Image description

  6. Finally, a PAT is generated:
    Image description

This is the command with the PAT generated above:

git clone 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@github.com/<your account or organization>/<repo>.git
Enter fullscreen mode Exit fullscreen mode

Top comments (0)