How to update a GitHub access token via command line

Viewed 3445

I use the git integration with VSCode and got the notification today that I need to renew my access token. I did so and have my new token (which I obtained through the web interface). Now I need to set my local git configuration to use the new token instead of the old one which will expire in a few days.

The VSCode docs suggest the following:

To execute the 'GitHub: Set Personal Access Token' type Ctrl+Shift+p in VSCode to open the command palette and type 'GitHub: Set Personal Access Token'. You will then be prompted to enter the token generated from GitHub.

This option isn't available in my git integration in VS code (maybe I need an update?)

How can I do this from the command line?

1 Answers

If you want to update Github Personal Access Token in VSCode, you need to install Github Extension

You can also update Github Personal Access Token via command line

  1. Open a command line and set the current directory to your project root

  2. Run the command to set remote access via a token

    git remote set-url origin https://username:token@github.com/username/repository.git

Example:

git remote set-url origin https://exampleuser:b8c28127***63gu56b2d@github.com/exampleuser/exampleproject.git
Related