How to update Github’s Personal Access Token on a local machine?
To update your Personal Access Token on a local machine, follow these steps:
- Go to your GitHub settings page. You can find this by clicking on your profile picture in the top right corner of the page and selecting “Settings” from the drop-down menu.
- In the left-hand menu, click on “Developer settings.”
- Under “Personal access tokens,” click on the “Generate new token” button.
- Give your token a name and select the desired scopes. Scopes control what your token can access on GitHub.
- Click the “Generate token” button.
- Copy the generated token and store it in a secure location.
Now, update locally
Replace the old token in your local machine with the new one. This will depend on how you are using the token. For example, if you are using it to authenticate with the GitHub API, you will need to update the token in your code or configuration file.
If you are using SourceTree app on Mac, go to Spotlight search, find Keychains, delete the github.com Access Key. Then, when you try to fetch or pull anything via SourceTree, it will ask you for the credentials. Put in you new access token and that is it!
If you are using VSCode, you can update your Personal Access Token manually, by this command:
git remote set-url origin https://user:ghp_g95p5Rm****[email protected]/user/example.git
All you have to do is to specify your username and token for the repository url.
Note: It is a good practice to rotate your Personal Access Tokens regularly to ensure the security of your account.