Git error fatal: Authentication failed

2020-02-16 06:09发布

I am trying to use git to push my repository to a visual studio team services project, but I get the error:

fatal: Authentication failed for (url of team project

I am using the cmds:

git remote add origin
     https://XXXXXXX.visualstudio.com/DefaultCollection/_git/project

git push -u origin -–all

Any idea of the fix for this?

Thanks!

13条回答
beautiful°
2楼-- · 2020-02-16 06:45

All i needed were the correct credentials. while deploying to a web app, i had to go to Deployment Center, Deployment Credentials. And then use either the App Credentials or create User Credentials. After this, delete the cached credentials on the local machine (windows: Control Panel\User Accounts\Credential Manager). run "git push webapp master:master" again, enter either of the Deployment Credentials. This worked for me.

查看更多
太酷不给撩
3楼-- · 2020-02-16 06:46

My solution was a little bit different and faster :)

  1. Go to Windows Credentials (Start-> Windows Credentials) and remove credentials for your repository (they starts with git:xxx)
  2. Go to VSCode and in Terminal write:

    config credential.helper wincred

  3. Go to Visual Studio (no VSCode) and make a git pull. A popup will show asking for credentials. Put your credentials for the repo

  4. Go to VSCode and make a git pull. Credentials were automatically fetched from wincred store

Credentials are automatically created and stored in wincredentials, so the next time you cannot be asked for credentials. (also a Personal Access Token will be provided from visualstudio.com if you are using DevOps hosted git repo).

查看更多
做个烂人
4楼-- · 2020-02-16 06:47

In the case you are on something else then windows and your boss is forcing you to use azure devops, and you don't want to use SSH, and you want to use to plain old way, do the following.

You have to enable 'Alternate credentials' (I know it's annoying) or you need to create an access token. Creating an access token in this case is more like a temporary random password. If you use the windows tooling it is done for you.

Any way, go to Security in the profile context menu in the right upper corner.

Security settings

Then if your boss/manager/dude that has the admin rights is favoring you the 'Alternate credentials' are enabled. Otherwise accept your fate and generate a 'Personal access token'.

Security settings

查看更多
姐就是有狂的资本
5楼-- · 2020-02-16 06:49

I've tried lots of options, but the one that worked for me was to:

  1. Download the Git Password Manager from its Releases section

  2. Try to do simple git fetch which will automatically bring the window(alternate to default windows one for example) and ask to enter username and password but with more elegant way than the standard one.

After correctly entering the credentials it worked, though I was getting an error before.

P.S. If you are getting "Wrong Credentials" kind of errors always check if the repository username and password are correct. If you hesitate just reset the password and try to use the same one in the Git Password manager window.

查看更多
倾城 Initia
6楼-- · 2020-02-16 06:51

Delete '.git/config' and try again. Attention this will may reset some git settings too!

I've tried alternative credentials and Personal Access Token for many times with right credential and it kept telling me "fatal: Authentication failed".

Finally, I found there is a file named ".git/config" located at the root of my Repo. I deleted this file and type in my credentials again, it worked.

查看更多
家丑人穷心不美
7楼-- · 2020-02-16 06:54

I had a same issue recently (visual studio 2017 & Windows 10), and solved it using the following method:

Control Panel --> Credential Manager --> Manage Windows Credentials --> Choose the entry of the git repository, and Edit the user and password.

Done.

查看更多
登录 后发表回答