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:

  1. Open a command line window on your PC or Terminal on Mac

  2. Set the current directory to your project root

    cd C:\Users\Giddy\source\repo\MySampleProject
    
  3. 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://sampleuser:a7b19929***58fe65d1c@github.com/sampleuser/sampleproject.git
    

Leave a Comment