Reputation: 1752
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.
Upvotes: 76
Views: 151442
Reputation: 839
Git stopped using account password for code push, instead generate 'personal access token' from git account and use the same as password for code push. It absolutely worked for me to resolve this error.
Note : Git doesn't store 'personal access token', so copy it in your file/machine for future/multiple use.
Upvotes: 2
Reputation: 19
I faced a similar problem. I was coding in vs code. So, I just tried another terminal to push my code and it works for me!!
Upvotes: -1
Reputation: 71
In case of using VSCode git graph's buttons that result in message error like this:
Unauthorized fatal: Authentication failed ... unable to fetch from remote(s)
This worked for me:
Upvotes: 0
Reputation: 646
Configure VS Code Github authentication using Github CLI, gh.
gh auth login
repo
, read:org
, workflow
If you've gone through the above steps before but your personal access token has expired, you can simply generate another personal access token and paste inside the /home/<user>/.config/gh/hosts.yml
file. Note that this file path is for linux/MAC users. Windows users should be able to locate similar path in their filesystem.
Upvotes: 0
Reputation: 1565
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:
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.
Upvotes: 90
Reputation: 71
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.
Created .gitconfig
in my home directory and added the following
[user]
name = {your github username}
email = {your email}
[credential]
helper = store --file ~/.git-credentials
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
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.
Your personal access token (PAT) will be exposed as clear ASCII text and can be read if anyone has access to your user account.
Upvotes: 7
Reputation: 4200
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:
Upvotes: 2
Reputation: 1752
I solved it by following Caching your GitHub password in Git.
The steps are as follows:
git config --global credential.helper wincred
Upvotes: 65
Reputation: 29
git remote set-url origin https://USUARIO:[email protected]/URL.git
worked for me!
Upvotes: 0