· Travis Rodgers · Programming  · 2 min read

How To Update Your GitHub Personal Access Token (and add origin)

When your GitHub personal access token expires, it leaves you with an unauthenticated remote origin. In this post, I'll show you how to update your remote origin with your newly authenticated token.

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:

https://[email protected]/myusername/travis-media-website.git

The format is https://[PERSONALACCESSTOKEN]@github.com/[USERNAME]/[REPO].git

So to update this expired token, there are two steps:

  1. 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.

  1. Now add a new remote with your updated GitHub personal access token:
git remote add origin https://[PERSONALACCESSTOKEN]@github.com/[USERNAME]/[REPO].git

That’s it.

Now you should be able to push, pull, and do whatever your personal access token grants you.

    Share:

    Related Posts

    View All Posts »
    5 Steps to Learn React in 2025

    5 Steps to Learn React in 2025

    React is one of the most popular front-end JavaScript libraries. Let's break down the essential steps to learn React in 2025.

    5 Reasons Laravel is Trending in 2024

    5 Reasons Laravel is Trending in 2024

    In this article, I want to give 5 reasons why I think many more people are finding a newfound enjoyment or a re-found enjoyment in the Laravel ecosystem.