Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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 = ############ 
like image 485
zkirkland Avatar asked Jul 15 '13 16:07

zkirkland


People also ask

Why Git push is not working?

You need to use git pull and resolve the difference between your local changes and the remote changes before you can git push . There is still a commit in the remote branch initializing the repo that may not be in your local version.


2 Answers

On Windows, try the following steps to edit or remove the saved credentials:

  1. Click Start
  2. Type: Credential Manager (on Windows 10, this is under "StartSettings". Then search for "Credential Manager")
  3. See the Windows Credentials Manager shortcut and double-click it to open the application.
  4. Once the application 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. Lather, rinse, repeat as necessary.

Enter image description here

like image 39
Pradeep Avatar answered Oct 02 '22 14:10

Pradeep


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 [email protected]:USERNAME/REPONAME.git 
like image 153
rc0r Avatar answered Oct 02 '22 14:10

rc0r