How To Update Your GitHub Personal Access Token (and add origin)
What do you do when your GitHub personal access token expires?
Sure, you create a new one in Github for another 30, 60, or 90 days by going to https://github.com/settings/tokens, clicking Generate New Token, and creating a new token (be sure to at least check the repo scope and also copy your generated token, it’s only shown once).
But how do you update your repo’s remote origin to authenticate with that personal access token?
If you run the command
git remote -v
…it will show you your current origin. And if you authenticate with a personal access token, it may look something like:
The format is
So to update this expired token, there are two steps:
- Remove your current, expired, remote URL by running:
git remote remove origin
Now by running
git remote -v you’ll see you no longer have a remote origin assigned.
- Now add a new remote with your updated GitHub personal access token:
git remote add origin https://[PERSONALACCESSTOKEN]@github.com/[USERNAME]/[REPO].git
Now you should be able to push, pull, and do whatever your personal access token grants you.
** This article may contain affiliate links. Please read the affiliate disclaimer for more details.
You May Also Like
Become a Web Developer From Scratch in 2023
The Exact Blueprint… The Exact Course… And How To Land …