I use the git integration with VSCode. I have my new token (obtained through the GitHub web interface). How do I put it in?
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. How can I do it from the command line?
If you want to update your GitHub Personal Access Token in VSCode, you can install the GitHub Extension.
You can also update your token via the command line.
Note that this method writes your token to the .git/config
file in plain text which may expose it for use by others or potential unintentional redistribution.
Open a command line and set the current directory to your project root
Run this command to set remote access via a token:
git remote set-url origin https://username:[email protected]/username/repository.git
For example:
git remote set-url origin https://exampleuser:b8c281*****[email protected]/exampleuser/exampleproject.git
The problem with the top voted answer is that your token is written to the .git/config
file in plain text which exposes it for use by others or potential unintentional redistribution.
First, remove your existing git credentials. The next time you perform a Git operation, you will be prompted for a username and password. Enter the new token as your password.
To clear credentials on Windows, open the Credential Manager (search "credential manager" in the Windows search box). Then select the "Windows Credentials" button, find Git, and click "remove".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With