Error message 'Authentication failed on the git remote'

Visual Studio-Code

Visual Studio-Code Problem Overview


I'm trying to push, pull, and whatever to my GitHub repository from Visual Studio Code.

I enter my username and password, but I'm getting the error:

> Authentication failed on the git remote.

I just logged in on github.com with the same user/password. I tried creating a personal access token, using it as a password, but I got the same error.

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

I believe I have found a solution to this problem. None of the solutions above worked for me. I think the root cause of this issue is that GitHub has ended support for password authentication on August 13, 2021. Instead a personal access token needs to be used.

The steps to solve this issue are as follows:

  1. Create a personal access token on GitHub.com. Tutorial here
  2. Go back to Visual Studio Code and open terminal. Type in the following command with your own user information:
git remote set-url origin https://<TOKEN>@github.com/<user_name or organization_name>/<repo_name>.git

In case you would like to follow a video guide, this one proved to be quite helpful.

Solution 2 - Visual Studio-Code

I solved it by following Caching your GitHub password in Git.

The steps are as follows:

  1. Download and install Git for Windows
  2. Run Git Bash, 'cd' to the repository directory and enter git config --global credential.helper wincred

Solution 3 - Visual Studio-Code

I had the same issue with my Visual Studio Code on Linux cloning a Visual Studio Git repository.

It was Solved by setting up the Alternate Authentication Settings under security settings on {your-account}.visualstudio.com

Screenshot:

See the screenshot

Solution 4 - Visual Studio-Code

It happened to me after GitHub changed its policy on 13 August 2021 to authenticate using a personal access token (PAT) instead of a password.

I did these steps for myself. I am on Lubuntu 20.04.

  1. Created .gitconfig in my home directory and added the following

    [user]
       name = {your github username}
       email = {your email}
    [credential]
       helper = store --file ~/.git-credentials
    
  2. Created .git-credentials in my home directory as you can see above and added the following

    https://{your github username}:{your github PAT}@github.com
    
  3. Final step: Restart your terminal and voilà! Try to commit/push/pull in an existing Visual Studio Code Git folder and everything will work as before.

Security Issue

Your personal access token (PAT) will be exposed as clear ASCII text and can be read if anyone has access to your user account.

Solution 5 - Visual Studio-Code

git remote set-url origin https://USUARIO:[email protected]/URL.git

worked for me!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjoakimView Question on Stackoverflow
Solution 1 - Visual Studio-CodealeksejjjView Answer on Stackoverflow
Solution 2 - Visual Studio-CodejoakimView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeADM-ITView Answer on Stackoverflow
Solution 4 - Visual Studio-CodeUdayView Answer on Stackoverflow
Solution 5 - Visual Studio-Codeivonildo bispo santosView Answer on Stackoverflow