23

I'm trying to set up Git on a fresh machine, and I'm having trouble authenticating with my remote repository.

I have limited experience with Git, but I have successfully done the following before:

  • Create local repository ($git init)
  • Connect with remote repository ($git remote add origin https://[my remote repository])

Everything goes well up until this point. However, when I try to interact with the remote repository - pull, clone or push - either through command line or TortoiseGit, I am greeted with the following error message upon entering my credentials:

Failed to erase credential: Element not found

fatal: Authentication failed for https://[my remote repository]

It obviously seems like some sort of authentication issue - however, I can log into the web interface of the remote repo just fine, so I'm certain I'm using the correct un/pw. I've installed the Windows Credential Store for Git, but that throws the exact same error message.

Google hasn't been much help - this solution seems to be Vista / 32bit specific (I'm Win7 / 64bit), and this SO question has been removed, leaving me none the wiser.

Now, I'm sure there's a simple solution to my problem, but I've been at it all day with no progress. Anybody able to give me a pointer?

Thanks in advance!

Edit: Here's the full results of a clone command:

I:\KODE\_Git\myproject>git clone https://...

Cloning into 'myproject'...

Username for 'https://...': myuser

Password for 'https://myuser[at]...':

fatal: Authentication failed for 'https://...'

Community
  • 1
  • 1
Medjeti
  • 341
  • 1
  • 3
  • 8
  • Why not simply clone it? `git clone https://...` – michas Jun 12 '13 at 21:31
  • Thanks for the suggestion. Unfortunately Clone, Push and Pull all throw the same error. – Medjeti Jun 12 '13 at 21:35
  • Could you try a clone from command line and include the complete screen content? – michas Jun 12 '13 at 21:43
  • Is it a github URL? did you already create the repository there? How did you install your git itself? – michas Jun 12 '13 at 21:44
  • Thanks for your feedback! The remote repository is a private one, hosted by my company. I use it every day at the office, and I'm now trying to get my home machine up and running to. – Medjeti Jun 12 '13 at 22:05
  • DL'ed Git from here: http://git-scm.com/download/win – Medjeti Jun 12 '13 at 22:16
  • Interesting that so many people have this problem but everyone for other reasons. – markus Nov 09 '13 at 22:16
  • The issue will be solved by changing the password. See my post # http://stackoverflow.com/a/30705740/4985705 – Max Jun 08 '15 at 09:55
  • Maybe you are looking for alternate auth. credentials for programs that use git outside of VS? [This is the answer](http://stackoverflow.com/a/21808395/1042934) – Ognyan Dimitrov Jul 30 '15 at 12:56

14 Answers14

14

I had the same error in windows. It happened after i changed the credentials in the Control panel -> Users -> Manage credentials.

I fixed it by adding a new credential:

git:https://github.com (web credentials) and username and password.

Erik
  • 141
  • 1
  • 2
6

I had this problem with github. In my case the source of the problem was Two-factor authentication. I had it turned on, and when I turned it off - I got rid of that credential-error.

That's a shame though that I have to keep Two-factor authentication off because of it.

retif
  • 1,495
  • 1
  • 22
  • 40
  • I just installed Git version 1.9.0, and also changed my GitHub password (due to the Heartbleed SSL bug), and also ran into this problem. Like retif, I had also enabled two-factor authentication, and it turns out that this was the culprit. After disabling two-factor authentication, everything works fine. For the record, here's the error output I was seeing: Failed to erase credential: Element not found remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/hollasch/ray4.git/' – Steve Hollasch Apr 11 '14 at 07:03
  • Wow was that frustrating, I encountered the same, thanks for the answer as I was hunting everywhere. Same deal, changed password due to Heartbleed and enabled two-factor – Denis Pitcher May 01 '14 at 08:30
  • I did some digging as I wasn't satisfied. There are instructions here: http://stackoverflow.com/questions/13800289/configure-git-clients-like-github-for-windows-to-not-ask-for-authentication on how to create an application access token which allows you to preserve your two factor auth – Denis Pitcher May 01 '14 at 08:48
5

I´m using GitExtension 2.46 (including msysgit 1.8.3) and I encountered the same problem. Also reverting the installation of GitExtension 2.44 (with msysgit 1.8.1.2) doesn´t solve the problem.

After some testing I came to the conclusion that my password is the problem, cause the latest release of the git-credential-winstore.exe fixes an issue with "=" in passwords.

My password does not contain any =, but it contains a " and §. So my first thought was to update the installed version of git-credential-winstore.exe to the latest Version 1.2. I updated the file manually and tried it again, but with no success.

Finally i have changed my password to not include any special characters and now it works.

Jehof
  • 34,674
  • 10
  • 123
  • 155
  • Thanks for this workaround. As it is a workaround, I decided to test against latest release ([GCMW-1.4.0.exe](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.4.0)) and I always encounter this issue. So I just create an issue: [GCMW issue #226](https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/226) – boly38 Jun 22 '16 at 11:29
4

Looks like the remote server is not able to authenticate you.

You used an https:// URL. Therefore git uses https to connect to the remote repository. The server answers with 401 (Unauthorized) and your git client prints the above error message.

Not sure, why the server does not like you. Either name/password is not correct, or something strange is going on. Try to access the https:// URL with the browser. Maybe this gives you an idea what the servers problem might be.

You could also try to give name/password explicitly in the url: https://name:password@.... (But server will probably still refuse authentication.)

michas
  • 25,361
  • 15
  • 76
  • 121
  • The web interface at https://... works just fine, so I'm fairly certain my credentials are OK. I'm gonna have my server savvy buddy look at some logs tomorrow and see if we can figure it out. Thanks! – Medjeti Jun 12 '13 at 23:49
  • I had the same error `Failed to erase credential: Element not found`, and adding the password to the remote's url fixed the problem. I'm using Git Extensions 2.46. I didn't need to downgrade/upgrade my GitEx and/or Git. – mbenegas Sep 19 '13 at 09:41
  • Actually, adding username and password to the remote url helps. Which means something with the prompt is going wrong. Weird. – markus Nov 09 '13 at 22:05
3

EDIT: Confirmed, this seems to be an issue with Git v1.8.3 - switching to v1.8.1.2 solved the problem. Download here. Thanks for helping out!


Well, it just so happened that a colleague of mine had the exact same problem last night, independent of this question.

Like me, he had downloaded the latest official Git build - v1.8.3. He proceeded to uninstall the latest build and installed v1.8.1.2 instead - and that solved the problem.

I'll give this a go when I get the chance and report back.

Medjeti
  • 341
  • 1
  • 3
  • 8
3

With GitHub, you get this message if you are using 2-factor authentication and https Git.

The solution is to create a personal access token which you use in place of your password.

See https://github.com/blog/1614-two-factor-authentication

expdiant
  • 1,180
  • 1
  • 7
  • 8
1

Edit: It seems to be a curl bug/incompatibility with IIS when using anyauth and Windows Authentication actived

Edit 2: It seems that installating msysgit 1.8.0-preview-20121022 fixes the problems

Using more recente version of mssys git will fail with auth error. This can be reprocuced using curl/libcurl, the underlying Git provider for http/https.

C:\Program Files (x86)\Git\bin\curl.exe --anyauth http://user:password@server/tfs/defaultcollection/_git/repo/info/refs?service=git-receive-pack

This works well

C:\Program Files (x86)\Git\bin\curl.exe --digest http://user:password@server/tfs/defaultcollection/_git/repo/info/refs?service=git-receive-pack

So disabling Windows Authentication makes git work, but you loose everything else (access to services from VS or the TFS Management console !)

  1. On "tfs" node, activate "Digest Authentication" and disable everything else
  2. On "Team Foundation Server" node, activate "Digest Authentication" and disable everything else
  3. On "Team Foundation Server" node, do Manage Website > Restart

Was able to push and push tags after that (from git bash and git extensions)

Note: I use git 1.8.4.msysgit.0, git-credential-winstore 1.2 and Git Extensions 2.47.3

Note2: Don't know if enabling other types of auths at the same time changes anything

Note3: Not tried with passwords containing = or other "special" chars

  • I've had an issue connecting from the command line git.exe (either from Windows or Max OS X) to TFS 2013 on a Win 2008 R2 server which is on premise. This is the only post that I found that solved my issue. The authentication in IIS was not set to Digest and once I changed it things started working. – Christopher Hujanen Apr 28 '14 at 20:40
1

In my case I had to redefine (disable and enable again) Team Foundation Server alternate credentials, because password policy was strenghtened.

barbara.post
  • 1,581
  • 16
  • 27
1

If you're using the Windows Credential Store for Git then the problem may be that you're using the buggy 1.3 version.

Troubleshoot the issue on the command using:

cmdkey /list

to list your current credentials in the Windows Credential Store.

And to add your git credentials manually (for TFS Online in this case, but it's the same for Github):

cmdkey /generic:LegacyGeneric:target=git:https://mysite.visualstudio.com /user:MyName /pass:MyPass123

What I found was that after doing something like a git pull my credentials got deleted automatically.

Installing git-credential-store v1.2 fixed the problem for me. See: git push fails with git-credential-winstore

I also changed my "Alternate Credentials" password in my profile for my TFS Online account (their password policy has changed to now require 3 different character classes), as suggested in Barbara's answer.

Community
  • 1
  • 1
G. Lombard
  • 3,569
  • 1
  • 29
  • 30
0

I had the same issue just now but I guess the cause might be a bit different.

In my scenario I was trying to access a new TFS-git repo with the same account as I use to access another TFS repo. The solution for me was to reinstall the git-credential-winstore.exe application and reinstall it. I also removed the stored credentials in Windows credential manager. Link to git credentials application: http://gitcredentialstore.codeplex.com/

Hope this helps someone!

aeliusd
  • 469
  • 7
  • 18
0

I was struggling with this issue myself using Windows 2008 (32bit), Git, GitExtensions.

When prompted with the username/password box when attempting to push, I was getting the same message even though I was certain that I was using the correct username/password.

Adding the user/password when configuring the origin fixed this for me:

git config remote.origin.url https://user:password@bitbucket.org/username

Dan Smith
  • 26
  • 2
0

I ran into this same problem recently, and it was because I wasn't using the proper url.

bad url: https://github.com/blesh/myrepo

good url: https://github.com/blesh/myrepo.git <-- .git !!!

To check your remote urls:

git remote -v

To fix your remote origin url:

git remote set-url origin https://github.com/blesh/myrepo.git

Once I did this, everything worked fine again.

Ben Lesh
  • 107,825
  • 47
  • 247
  • 232
0

In our case, it was a problem with the server. Our IT guy said that the git server was unable to reach the authentication server.

I'm not sure what that means, but everything was promptly fixed after a quick server bounce and some other IT wizardry.

epb
  • 454
  • 4
  • 15
0

I was getting this error also. The only way to fix it was to create a secondary credential in visualstudio.com profile under credentials. Using the secondary credential with git extensions fixed the error.