git – How to add a GitHub personal access token to Visual Studio Code
git – How to add a GitHub personal access token to Visual Studio Code
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:UsersGiddysourcerepoMySampleProject
- 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
- Generate a personal access token from github.com
- Make sure to save your access token (e.g., ghp_pVC*****)
- Open your project with Visual Studio Code or navigate to your project in the terminal,
cd ~/path/to/your/project
- In the Visual Studio Code terminal,
git remote set-url origin https://<personal_access_token>@github.com/<your_username or organization_name>/<repo_name>.git
- Now you can try
git push
Note:
When generating a personal access token, make sure to enable workflow:
Hint
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)
git – How to add a GitHub personal access token to Visual Studio Code
Related posts
- pip – How to install Python package from GitHub?
- python – Converting a RGB color tuple to a six digit code
- django – Best practices for adding .gitignore file for Python projects?
- git – pip connection failure: cannot fetch index base URL http://pypi.python.org/simple/
- string – Whats the difference between str.isdigit, isnumeric and isdecimal in python?
- python – Fixed digits after decimal with f-strings