I received an email saying GitHub will require token authentication after August 13 2021. I want to ensure I don't have an interruption of service (push/pull) after this date. So I logged into GitHub and created a token for my single repository.
Now I want to use the token to push/pull my repository from GitHub, in Visual Studio Code, which uses Git and the command line, which I have installed on my Mac.
What do I do to add/replace the password from GitHub with the generated token I just created to push/pull from my repository? Can I do it from Visual Studio Code or does it get added from the terminal command line?
Setup Personal Access Token The 'GitHub: Set Personal Access Token' should be executed for that. 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.
If you are not redirected to VS Code, you can add your authorization token manually. In the browser window, you will receive your authorization token. Copy the token, and switch back to VS Code. Select Signing in to github.com... in the Status bar, paste the token, and hit Enter.
In Visual Studio, select Team Explorer from the View menu. In the Team Explorer pane, click the Manage Connections toolbar icon. Click the Connect link in the GitHub section. If none of these options are visible, click Manage Connections and then Connect to GitHub.
Follow these simple steps to set up GitHub authentication with a personal access token:
Open a command line window on your PC or Terminal on Mac
Set the current directory to your project root
cd C:\Users\Giddy\source\repo\MySampleProject
Run the command to set remote access via a token
git remote set-url origin https://username:[email protected]/username/repository.git
Example:
git remote set-url origin https://sampleuser:a7b19929***[email protected]/sampleuser/sampleproject.git
Tested on Visual Studio Code (Mac)
no need for an extra extension. I only trust official extensions, sorry. GitHub extension by KnisterPeter
cd ~/path/to/your/project
git remote set-url origin https://<personal_access_token>@github.com/<your_username or organization_name>/<repo_name>.git
git push
When generating a personal access token, make sure to enable workflow:
You can type git remote -v
to see your origin or upstream.
origin https://github.com/<username>/<repo_name>.git (fetch)
origin https://github.com/<username>/<repo_name>.git (push)
upstream https://github.com/<username>/<repo_name>.git (fetch)
upstream https://github.com/<username>/<repo_name>.git (push)
Also after setting git remote set-url origin https://<personal_access_token>@github.com/<your_username>/<repo_name>.git
Your git remote -v
should be something like:
origin https://<your_personal_access_token>@github.com/<username>/<repo_name>.git (fetch)
origin https://<your_personal_access_token>@github.com/<username>/<repo_name>.git (push)
If you get a message like this using the GitHub extension by KnisterPeter:
To enable the Visual Studio Code GitHub Support, please set a Personal Access Token
Go to Settings → Developer Settings → Personal Access Token
Or go directly to https://github.com/settings/tokens
Click Generate New Token
Go back to Visual Studio Code and open the Command Palette (Ctrl + Shift + P)
Type in GitHub: Set Personal Access Token
Paste in the value from your newly generated token
To see the output related to GitHub authentication:
At the time of writing, I'm on Visual Studio Code v1.56.0.
If you are not prompted for your username and password, your credentials may be cached on your computer. You can update your credentials in the Keychain to replace your old password with the token.
Updating credentials from the macOS Keychain
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