How to Clone from GitHub with a Fine-grained PAT
Fine-grained tokens sound like a good thing. And they are a good thing. You get a token that can access just one private repository, can only do a few specific actions, and rots away after a certain time. Neat, right?
But. The feature has been in beta for almost two years and the best documentation for the task in the title is on stackoverflow. Sad. Making a token to clone a repo really isn’t a single button click. It’s actually, I’d say, pretty unfriendly. But oh well, it can be done somehow, I just need to document it here a bit.
So how? To generate a token, go here and from the giant pile of permissions click the following:
- Commit statuses - Access: Read and Write
- Contents - Access: Read and Write
- Pull requests - Access: Read and Write
- Metadata - Access: Read
Then copy the token and simply:
git clone https://githubtoken@github.com/user/repo.git
Just the token, no user. Not even the oauth2 user mentioned on stackoverflow above.
And that’s it.