Git push results in "Authentication Failed"
GitAuthenticationGithubVisual Studio-CodeGit Problem Overview
I have been using GitHub for a little while, and I have been fine with git add
, git commit
, and git push
, so far without any problems. Suddenly I am having an error that says:
> fatal: Authentication Failed
In the terminal I cloned a repository, worked on a file and then I used git add
to add the file to the commit log and when I did git commit
, it worked fine. Finally, git push
asks for username and password. I put those in correctly and every time I do this, it says the same error.
What is the cause of this problem and how can I fix it?
The contents of .git/config
are:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = http://www.github.com/######/Random-Python-Tests
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
name = #####
email = ############
Git Solutions
Solution 1 - Git
> If you enabled two-factor authentication in your GitHub account you > won't be able to push via HTTPS using your accounts password. Instead > you need to generate a personal access token. This can be done in the > application settings of your GitHub account. Using this token as your > password should allow you to push to your remote repository via HTTPS. > Use your username as usual.
Creating a personal access token
You may also need to update the origin for your repository if it is set to HTTPS. Do this to switch to SSH:
git remote -v
git remote set-url origin git@github.com:USERNAME/REPONAME.git
Solution 2 - Git
On Windows, try the following steps to edit or remove the saved credentials:
- Click Start
- Type: Credential Manager (on Windows 10, this is under "Start → Settings". Then search for "Credential Manager")
- See the Windows Credentials Manager shortcut and double-click it to open the application.
- Once the application is open, click on the Windows Credentials tab.
- Locate the credentials that you want to remove/update. They will start with "git:" and might begin with "ada:"
- Click on the credential entry. It will open a details view of the entry.
- Click Edit or Remove as required and confirm.
- Lather, rinse, repeat as necessary.
Solution 3 - Git
Maybe you have changed the password recently for you Git account.
You could try the git push
line with the -u
option:
git push -u origin branch_name_that_you_want_to_push
After executing the above command, it will ask for a password. Provide your updated password.
Solution 4 - Git
It happens if you change your login or password of git service account (Git). You need to change it in Windows Credentials Manager too. type "Credential Manager" in Windows Search menu open it.
Windows Credentials Manager->Windows Credential and under Generic Credentials edit your git password.
Solution 5 - Git
On Windows, this worked for me, and it also remembers my credentials:
-
Run Git Bash
-
Point to the repository directory
-
Run
git config --global credential.helper wincred
Solution 6 - Git
First, you can make sure to use the proper URL:
git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git
Then, if it was working before, and if it wasn't asking for your username, it must be because you had stored your credentials (login/password) in a $HOME/.netrc
file, as explained here. You can double check those settings, and make sure that your proxy, if you have one, hasn't changed.
Check the output of git config --global credential.helper
.
And make sure the credentials are your GitHub user account, and a PAT (Personal Access token).
You can update your credentials using the Git credential helper, as in here.
If that still doesn't work, you can switch to an SSH URL:
git remote set-url origin git@github.com:zkirkland/Random-Python-Tests.git
But that means you have published your SSH public key in your Account settings.
For Visual Studio Code specifically, see also "git push
: Missing or invalid credentials. fatal: Authentication failed for 'https://github.com/username/repo.git'"
You can unselect the setting git.terminalAuthentication
to avoid the error message.
Solution 7 - Git
Basically my credential was expired, and I was facing the issue.
The following two commands helped me:
git config --global --unset credential.helper
git config credential.helper store
It will ask you for credentials next time when you try to push.
Follow the below guidelines for more details for secured and unsecured storage of the user name and passwords:
Solution 8 - Git
On Windows, if you found an authentication error problem when you entered the correct password and username, it's a Git problem. To solve this problem, when you are installing the Git in your machine, uncheck the Enable Git Credential Manager option.
Solution 9 - Git
I think that for some reason GitHub is expecting the URL to NOT have subdomain www. When I use (for example)
git remote set-url origin https://www.github.com/name/repo.git
it gives the following messages:
remote: Anonymous access to name/repo.git denied
fatal: Authentication failed for https://www.github.com/name/repo.git
However, if I use
git remote set-url origin https://github.com/name/repo.git
it works perfectly fine. Doesn't make too much sense to me... but I guess remember not to put www in the remote URL for GitHub repositories.
Also notice the clone URLs provided on the GitHub repository webpage doesn't include the www.
Solution 10 - Git
I was getting the same error. I tried all the solutions whichever mentioned in this page, but they didn't work. Finally, I found the solution.
These kinds of error comes if sometimes your system password has changed recently anytime. It will try to validate from the old password. So, follow these steps:
- Go to Control Panel
- Click on User Accounts
- Under Credentials manager
- Go to Manage Windows Credentials
- Go to Generic Credentials
- Expand the Git server tab
- Click on Remove from vault
- Also, you can click Edit and change your password stored here directly.
Solution 11 - Git
Before you try everything above, try to git push
again, yes it works on me.
Solution 12 - Git
I'm not really sure what I did to get this error, but doing:
git remote set-url origin https://...
didn't work for me. However:
git remote set-url origin git@bitbucket.org:user/repo
somehow worked.
Solution 13 - Git
I've ran into
git fetch
fatal: Authentication failed for 'http://...."
after my Windows password had expired and was changed. Multiple fetches, reboot and even reinstall of Git with Windows Credential Manager didn't help.
Surprisingly the right answer is somewhere here in comments, but not in answers (and some of them are really weird!).
You need to go to Control Panel → Credential Manager → Windows Credentials and update you password for git:http://your_repository_address
Solution 14 - Git
I was adding to Bitbucket linked with Git and had to remove the stored keys, as this was causing the fatal error.
To resolve, I opened the command prompt and ran
rundll32.exe keymgr.dll, KRShowKeyMgr
I removed the key that was responsible for signing in and next time I pushed the files to the repo, I was prompted for credentials and entered the correct ones, resulting in a successful push.
Solution 15 - Git
The same error (Windows, Git Bash command line). Using https which should prompt for login credentials but instead errors:
$ git pull origin master
fatal: Authentication failed for 'https://github.com/frmbelz/my_git_project.git'
$ git config -l
...
credential.helper=manager
...
$ git config --global --unset credential.helper
$ git config --system --unset credential.helper
git pull
now prompted for username/password prompts.
Solution 16 - Git
In my case, I recently changed my windows password and I have SSH key configured for git related actions (pull, push, fetch etc.,), after I encountered the "fatal: Authentication failed" error, I updated my password in the windows credential manager (Control Panel\User Accounts\Credential Manager)for all items starting with git:..., and tried again, worked this time!
Solution 17 - Git
I had the same problem. I set the URL in this way:
git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git
I also removed this entry from the configuration file: askpass = /bin/echo
.
Then "git push" asked me for username and password and this time it worked.
Solution 18 - Git
If you have enabled the two-factor authentication on your GitHub account, then sign in to your GitHub account and go to
to generate a new access token, copy that token, and paste as a password for authentication in the terminal.
Solution 19 - Git
Just from your .config file change:
url = http://www.github.com/###user###/Random-Python-Tests
To:
url = http://###user###@github.com/###user###/Random-Python-Tests
Solution 20 - Git
I started experiencing this issue on Visual Studio Code in Ubuntu 20.04 yesterday.
I did not make any changes to my GitHub credentials, neither did I change anything in the project, but I run any git command to communicate with my remote branch like:
git pull origin dev
I get the error below:
> remote: Repository not found. fatal: Authentication failed for 'https://github.com/MyUsername/my-project.git/';
Here's what worked for me:
I tried recloning the project and then running the git pull command but it did not work.
git clone https://my-git-url
I tried setting my credentials again using the below commands but still no luck:
git config --global user.email "[email protected]"
git config --global user.name "John King"
I tried removing the remote repository and re-adding it using the below commands, but still no luck:
git remote remove origin
git remote add origin https://my-git-url
Finally, I decided to try using my default Ubuntu terminal and it worked fine. My big guess is that it's a bug from Visual Studio Code from the last update that was made some few hours before then (See the screenshot that shows that a Release was done on the same day that I was having the issue). I mean I set up Visual Studio Code using snap
, so probably it might have been updated in the background a few hours before then.
Hopefully, they will get it fixed and git remote operations will be fine again.
Solution 21 - Git
If you are on Windows and trying to push to a Windows server which has domain users working as repository users (TFS), try getting into the TFS URL (i.e. http:\\tfs
) with Internet Explorer. Enter your domain account credentials and let the page appear.
Caution: Only use Internet Explorer! Other browsers won’t change your system credentials.
Now go to Git Bash and change your remote user for the repository like below:
git config user.name "domainName\userName"
And done. Now you can push!
Solution 22 - Git
Got the above error message when I updated my computer password. Reset my git credentials using the following steps:
Go to Control Panel > User Accounts > Credential Manager > Windows Credentials. You will see Git credentials in the list (e.g. git:https://). Click on it, update the password, and execute git pull/push command from your Git bash and it won't throw any more error messages.
Solution 23 - Git
For me, I forgot that I had changed the password on github.com, and my keychain for shell authentication never updated to that new password.
Deleting everything Git from my keychain and then rerunning the Git request helped solve the issue, prompting me again for the new password.
Solution 24 - Git
I tried the token verification method and got it to work ~3 times and wasted around 2 hours of time for that. For some reason it does not work very well for our company.
My solution was to change the authentication method from HTTPS to SSH. Here is a Github guide (https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent).
After you have created the SSH key, remember to change the SSH address origin:
git remote add origin git@github.com:user/repo.git
Solution 25 - Git
I was getting below error when trying to push to github remote
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Solution SSH Keys were missing on github account
-
Copy local public ssh keys from
~/.ssh
directory -
Paste to
Github > Settings > SSH and GPG Keys > New SSH Key
-
Try
ssh -T [email protected]
This should outputHi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
Solution 26 - Git
Just to chime in here, what fixed the issue for me was I simply canceled out of the initial prompt, the SSH one opened up with my Bitbucket account, I entered the password there and everything worked as expected.
Solution 27 - Git
I was facing the same issue on Windows. Most of the time, I normally face the issue due to using multiple Git accounts. If you are on Windows, please do open the terminal as an administrator and try running the commands again. Make sure that you have the administrator access rights.
Solution 28 - Git
I also ran into the error (that's why I am landed here), but none of the suggestions worked for me. This was my very first time I tried to deploy a local Git repository to Azure.
When I got this error, I reset my credentials (by clicking the link in Azure) after a few tries. The problem is that at this point it tells me my user name is already taken, so I also changed my user name to another one.
In the end, I manually deleted the .git folder on my local drive, and redeployed it without problem.
Solution 29 - Git
Problem Statement: "git fatal authentication failed". I am using Bitbucket.
Solution:
I simply deleted the user from using the access management of Bitbucket and then added the same user. The .gitconfig file is simple:
[user]
name = BlaBla
email = [email protected]
[push]
default = simple
Solution 30 - Git
With correct credentials if the problem prevails:
If you’re using Android Studio 2.1 beta then it’s a bug. Upgrade to beta 2 (3 MB update file). This worked for me.
Solution 31 - Git
Make sure you have write permission to push.
read ***write*** admin
Solution 32 - Git
In Android Studio Canary build 3.1+, if you are using the Android Studio Git tool, then you can use following:
- Click on Android Studio
- Click on Preferences...
- Go in Version Control → GitHub
- Here change Auth type to Password
- This step will require you to enter login and password. Enter your GitHub user name as the login and GitHub password as the password.
- Click on the Test button.
If the connection is successful, then you are done and you can use the Android Studio GitHub GUI client.
Solution 33 - Git
If you are using SSH and cloned with HTTPS, this will not work.
Clone with SSH and then push and pulls should work as expected!
Solution 34 - Git
In case this is tangentially helpful, since this question is now a top hit for http authentication problems with git: Windows Credential Manager had stored my password correctly, and since I was using Git LFS I configured an http URL instead of the usual ssh://.
My problem was that my corporate password policy forced an account password change but I never updated my stored credentials (since I always use an ssh key).
Simply updating the password directly in the Wincred GUI worked: just look for a git:https://<your-url>
entry.
Solution 35 - Git
This happened to us after forcing "Two Factor Authentication" before login from Gitlab. We had to paste the text inside id_rsa.pub to Gitlab, and then reintroduce the repository in VS code using the terminal.
Solution 36 - Git
This the way, I resolved my access denied problem in GIT GUI and git bash.
This SSH key is copy-pasted in the GitHub access token.
For me everything was fine, I also tried the Windows Credentials Manager but then also the problem was not resolved. Then suddenly, I got pop up from the firewall, which was the main culprit behind all. After I clicked on allow manually then I could fetch or push to GitHub.
Solution 37 - Git
I had just enabled two factor authentication for my Github account, so I disabled two factor authentication and I was able to login with my UID and PWD
Solution 38 - Git
Given Solution: Using a Personal Access Token is one way of bypassing this problem. I don't have two-factor authentication enabled but whenever, I would login to a new PC I get email verification code to verify PC.
Solution: You can login to GitHub on a browser and verify your identity, that will let GitHub know to trust that PC. Afterwards, login with bash and this time your login should work as usual because now you are whitelisted.
Note: If you have any existing GitHub account and want to switch, then, delete it in Credentials Manager > Windows Credentials (Generic Credentials Section)
. Doing so will allow you to login when you make another git operation.
Solution 39 - Git
Enabling credentials helper solved the problem for me.
Solution 40 - Git
the quick GUI way of doing is:
- Firstly generate an access token via create app access token.
- then goto sourceTree's Settings(placed under the close button of the Source tree)
- A prompt will appear named "Repository Settings".
- There add/edit your repository path with
https://USER_NAME:[email protected]/REPO_NAME/PROJECT_NAME.git
or for github account
https://username:[email protected]/username/repo.git
Here the only change to mention is adding the additional accessToken generated by the above shared create app access token link into existing path url.
Solution 41 - Git
Make sure that your SSH key is added to your current SSH session.
-
Copy the output of
cat ~/.ssh/id_rsa.pub
to your GitHub settings under SSH and GPG keys. -
Update your current SSH session with
ssh-add ~/.ssh/id_rsa.pub
.
I am using Windows PowerShell with OpenSSH installed.
Solution 42 - Git
My solutions is:
- Access to
C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree
- Find the file
passwd
- Right click on that file and open with
Notepad
- You will see a list of username and password like:
> [email protected] > AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAMUOX3Q56PEuXEBSDFAFAASEH...
- Find the username and password you entered incorrectly, and delete it
- Save the file, and close it
- SourceTree will ask you again for your username and password on the next push or fetch
Solution 43 - Git
Of course, 2FA needs token instead of password for authentication.
In case if you encounter the same issue again in Windows system
- Uninstall Git
- Download and install the latest 'Git for Windows'
That will resolve your problem.