Advertisement
Advertisement


Git push results in "Authentication Failed"


Question

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 = ############
2019/08/09
1
768
8/9/2019 7:50:36 PM

Accepted Answer

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  
2018/07/17
1262
7/17/2018 12:01:45 AM


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

2016/01/04

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

2017/06/17

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.

2019/10/14

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.

2017/05/23

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

2018/04/30