It’s been a little while since I’ve had to add a new GitHub personal access token via the command line to be able to clone a GitHub repo. When I first started using GitHub I always used to go the easy route and just use a password. Developers and security people especially love to make things complicated though, so you can’t use a password anymore. This is actually an old change, not something new, but I found today that the easiest way to add a new PAT has actually change. According to Claude, you can use the GitHub CLI, “gh”, to add new PATs. This seems a little different than what I used to do before, so I wanted to write up a quick post on how to do this in case anyone else happens to be looking for the same information.
- Create your new Personal Access Token at github.com. After logging in, click on your profile icon > settings > developer settings > Personal access tokens > Tokens (classic) > Generate new token > Generate new token (classic)
- After Creating your new token, make sure to save it somewhere you aren’t going to lose it.
- Assuming you have brew installed on your Mac, run
$ brew install gh - In a new terminal window, login:
$ gh auth login - Select paste an authentication token, then paste in your PAT
- Last, in a new terminal window, clone your desired repo (assuming it’s your own repo which you have access):
$ git clone https://github.com/orgNameHere/repoNameHere