Git push results in “Authentication Failed”

I have been using Github for a little while and I have been fine with git add, git commit, and git push so far with no 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.

Does anyone have any idea what the cause of this problem is and how I can 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 = ############

33 Answers

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.

https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

You may also need to update the origin for your repository if set to https:

git remote -v 
git remote remove origin 
git remote add origin [email protected]:user/repo.git  

Try the following steps to Edit or Remove the saved credentials:

  1. Click Start
  2. Type: Credential Manager (On Windows 10, this is under “Start->Settings”. Then search for “Credential Manager”)
  3. See the Windows Credentials Manager shortcut and double-click it to open the application.
  4. Once the app is open, click on the Windows Credentials tab.
  5. Locate the credentials that you want to remove/update, they will start with “git:” and might begin with “ada:”
  6. Click on the credential entry, it will open a details view of the entry.
  7. Click Edit or Remove as required and confirm.
  8. Wash, rinse, repeat as necessary.

enter image description here

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.

This worked for me, and it also remembers my credentials:

  1. Run gitbash

  2. Point to the repo directory

  3. Run git config --global credential.helper wincred

May you have changed password recently for you git account You could try the git push with -u option

git push -u origin branch_name_that_you_want_to_push

After executing above command it will ask for password provide your updated password

Hope it may help you

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 you 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.

If that still doesn’t work, you can switch to an ssh url:

git remote set-url origin [email protected]:zkirkland/Random-Python-Tests.git

But that means you have published your ssh public key in your Account settings.

Basically my credential was expired, and I was facing above issue.

Following 2 command helped me:

git config --global --unset credential.helper

git config credential.helper store

It will asks you for credentials next time when you try to push.

Follow below guidelines for more details for secured and unsecured storage of user name and passwords:

https://git-scm.com/docs/git-credential-store

https://git-scm.com/docs/git-credential-cache

If you found authentication error problem when you entered correct password and username it’s git problem. To solves this problem when you are installing the git in your machine uncheck the enable git credential managerenter image description here

Hi, I was getting the same error i tried all the solutions whichever mentioned in this page, but didn’t work. Finally, i found the solution, So thought of posting it. Please correct me if i am wrong anywhere. These kinds of error comes if sometimes your system password has changed recently anytime. It will try to validate from old password. So, Follow these steps:

  1. Go to control panel
  2. Click on User accounts
  3. Under Credentials manager
  4. Go to Manage windows credentials
  5. Go to Generic credentials
  6. Expand git server tab
  7. click on Remove from vault

    • Also you can click edit and change your password stored here directly.

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.

I’ve ran into “$ git fetch fatal: Authentication failed for ‘http://….” after my windows password has expired and was changed. Multiple fetches, reboot and even reinstall of git with windows credential manager didn’t help.

Surprisingly the right answer 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://yourrepoaddress

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 [email protected]:user/repo

somehow worked.

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 PanelUser AccountsCredential Manager)for all items starting with git:…, and tried again, worked this time!

I had the same problem. I set url in that way:

git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git

I also removed from config file this entry: askpass = /bin/echo. Then “git push” asked me for username and password and this time it worked.

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.

Before you try everything above, try to git push again, yes it works on me.

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 TFS URL (i.e. http:\tfs) with IE. enter your domain account credentials and let the page appear.

CAUTION only use INTERNET EXPLORER! other browsers wont change your system credentials.

Now go to git bash and change your remote user for the repository like below :

git config user.name "domainNameuserName"

And done, now you can push!

If you have enabled the two-factor authentication on your Github account, then sign in to your GitHub account and go to: https://github.com/settings/tokens/new to generate new access token, copy that token and paste as a password for authentication in terminal.

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 [email protected]:user/repo.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 re-running the git request helped solve the issue, prompting me again for the new password.

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.

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.

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 try to deploy local Git 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.

Problem Statement: “git fatal authentication failed”. I am using bitbucket.

Solution: I simply deleted the user from using access management of bitbucket and then added the same user. The .gitconfig file is simple

[user]
    name = BlaBla
    email = [email protected]

[push]
    default = simple

with correct credentials if the problem prevails

if your using androidstudio 2.1 beta then its bug , upgrade to beta 2 (3 mb update file) , this worked for me

Make sure you have WRITE permission to push.

read ***write*** admin 

Make sure that your ssh key is added to your current ssh session.

  1. Copy the output of cat ~/.ssh/id_rsa.pub to your GitHub settings under SSH and GPG keys.

  2. Update your current ssh session with ssh-add ~/.ssh/id_rsa.pub

I am using Windows Powershell with Openssh installed.

in Android studio canary build 3.1+, if you are using Android studio git tool, than you can use following :

  • Click on Android Studio
  • Click on Preferences…
  • GO in VersionControl -> Github
  • Here Change Auth type to Password
  • This step will require you to enter login and password. Enter you github user name a s login and github password as password.
  • Click on Test Button.

If connection is successful , than you are done and you can use android studio github UI client.

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!

Leave a Reply

Your email address will not be published. Required fields are marked *