简体   繁体   中英

Git: Failed to erase credential: Element not found

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://...'

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.

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.

I´m using GitExtension 2.4 6 (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.

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

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.

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

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

在我的情况下,我不得不重新定义(禁用并再次启用)Team Foundation Server备用凭据,因为密码策略是强化的。

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.

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!

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

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM