16

As of today I'm getting errors when trying to use git commands with my repository in Azure-DevOps. The repositories sit in a project on DevOps that I can access with the same account and shows no sign of any recent changes to it. The steps I can take to reproduce it is:

  1. Open the command prompt and enter git fetch
  2. A window appears prompting for a login Login
  3. I click the account
  4. No password is prompted, but an e-mail arrives that a PAT has been created
  5. The command prompt yields an error

Error:

fatal: Authentication failed for `<link to repository>`

Things I've tried so far:

  • Restarting PC
  • Signing out and in on Visual Studio
  • Removing the .IdentityService folder
  • Removing and installing GIT
  • Removing and installing GIT For Windows in the Visual Studio Installer
  • Removing the cache folder %LOCALAPPDATA%\Microsoft\Team Foundation\7.0\Cache
  • Removing the cache folder %LOCALAPPDATA%\Microsoft\Team Foundation\8.0\Cache
  • Removing GIT and VS keys from the Credential Manager
  • Quite a few other things 'fixes' found online that did not solve my issue

Currently running:

  • GIT 2.21.0-64 bit
  • Visual Studio 2019

Edit:

I've attempted using Visual Studio Code with the Azure Repos 1.149.2 extension and get the same error. It yields me the Microsoft page to enter my code for device login which it grants, but using git commands give me the same error messages.

I've also had my profile removed from the Azure DevOps environment and re-added without success.

NotFound
  • 5,005
  • 2
  • 13
  • 33
  • 1
    Can you login to Azure DevOps and see the contents of the repo? (I have seen similar issues when someone has access to the Team Project but not its repos.) – Richard Apr 30 '19 at 10:25
  • 1
    try updating GCfW to the latest version and optionally forcing Visual Studio to use it: https://jessehouwing.net/configure-visual-studio-to-use-a-different-git-credential-manager-for-windows/ – jessehouwing Apr 30 '19 at 10:27
  • @Richard yes. I have access to the repo's on DevOps – NotFound Apr 30 '19 at 10:47
  • @jessehouwing I've attempted your solution, but unfortunately it didn't seem to have any effect. Helper was set to `manager` and I used changed it using vim to `C:\\\\Program\\ Files\\\\Git\\\\mingw64\\\\libexec\\\\git-core\\\\git-credential-manager.exe` as mentioned. – NotFound Apr 30 '19 at 12:03
  • 1
    @Bleep-Bloop looks like a permissions issue to me. Have you checked the team members on the project? Make sure your account is added on the project and that you're an Admin (not only in the organization, in the project settings specifically) – Jabberwocky Apr 30 '19 at 12:10
  • @Jabberwocky in the project settings under team I see myself in my team's group as usual. I added myself directly as `Administrator`, but it doesn't make any difference. Neither did adding myself directly without group. – NotFound Apr 30 '19 at 12:40
  • 1
    And if you manually create a PAT and close the auth screen every time it pops up? At some point it should ask for a standard user/pass prompt. Then enter `. ` for the user and the generated PAT as password. – jessehouwing Apr 30 '19 at 14:41
  • 1
    You can also turn on additional tracing for the credential manager by adding a variable in your environment settings prior to calling Git. Run `setx GIT_TRACE %UserProfile%\git.log`. Run `setx GCM_TRACE %UserProfile%\git.log` – jessehouwing Apr 30 '19 at 14:43
  • @jessehouwing thx for the suggestion. I tried the approach where it asks for user and pw. While it lets me fill in an username it doesn't let me type anything for the password. – NotFound May 01 '19 at 11:26
  • Then I suggest opening an issue here and attaching the log file generated by setting the values above: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues – jessehouwing May 01 '19 at 11:41

8 Answers8

12

Try and check the value of git config credential.helper.

If you see "manager", open the Windows Credentials Manager, and put as a password the PAT -- the Personal Access Token created -- (while keeping your regular login, associated to the remote URL)

Then try again, and see if the issue persists.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Thanks, but the issue still persists. I've also already tried removing and manually creating the key. – NotFound May 03 '19 at 06:39
  • @Bleep-Bloop Key? which key? SSH key? That popup is for HTTPS authentication (login/password, or login/PAT--token) – VonC May 03 '19 at 07:10
  • The key in the credential manager using a newly generated PAT. – NotFound May 03 '19 at 07:19
  • @Bleep-Bloop OK, then using that as a password should work (in the Windows Credential Manager, at the azure server URL entry) – VonC May 03 '19 at 08:09
  • 1
    nice. this one works for me. I searched the windows credential manager then in generic credentials, I look for my git repository link there and edit it's password and save the changes – aj go May 05 '20 at 05:51
12

To force the Git credential Manager to stop interfering, you can add the following to your global git config:

[credential]
    helper = 

This effectively turns off any credential manager. In Azure DevOps you can then configure a set of Git Credentials or a Personal Access Token and use that to connect directly.

It doesn't explain the problems you're experiencing. Given that your account seems to be Machine Bound and an AAD account a lot of things can be in play. This includes AAD Home-Realm Discovery and Single Sign-on and Azure Active Directory Guest accounts.

Another possible problem is your Windows Credential Store which has multiple locations where Azure DevOps and Git credentials are stored. And finally the account used to sign-in to Visual Studio 2019 to retrieve its license may be playing up.

With the information you've provided it's neigh impossible for us to help you resolve the issues without looking over your shoulder. I'd almost suggest filing an Azure support request if you have them available so an engineer can look with you.

Optionally run

git-credential-manager.exe erase

And pass in the following data

protocol=https
host=dev.azure.com
path=/jessehouwing/vsts-extensions/_git/vsts-github-tasks
{newline}

To tell git to delete the credentials stored for your account

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
4

I had the same situation - everything worked in VS 2017, but 2019 would not work. I found this article, which suggested I update the Git Credential Manager for Windows. My installed version (at C:\Program Files\Git\mingw64\libexec\git-core\git-credential-manager.exe) was 3 years old. Downloaded, installed, and the problem went away for me.

SouthShoreAK
  • 4,176
  • 2
  • 26
  • 48
2

In my particular case after many mails back and forth with Microsoft it turned out that two of my accounts somehow started conflicting with eachother causing weird errors. A nice example was that making changes to a wiki in DevOps would show a different account in the commit trial than the account I was logged into.

In the end Microsoft managed to fix it and I haven't had any issues since.

NotFound
  • 5,005
  • 2
  • 13
  • 33
2

I also faced this issue. This is what worked for me.

  1. Navigate to windows credentials: Control panel (cpl)-> user accounts -> Windows credentials-> Generic credentials Screenshot of Windows credentials

  2. Locate the url you have issues cloning (under Generic credentials), it will be prefixed with git: and remove that entry and close the control panel. Screenshot of Remove entry

  3. Close Visual Studio (if open) and reopen and try to clone now, Visual studio will prompt for credentials.

I hope that helps. :)

Gul B
  • 21
  • 2
  • I had to do the same thing except with removing windows credentials instead of generic credentials. But after I removed that, it started working again – mheskamp Jan 31 '23 at 17:04
1

I had a similar problem in VS2019, I moved laptops and it refused to authenticate despite me deleting and changing the credentials using credentials manager. I'm linked to a repository in Assembla and In the team explorer window under repository settings I noticed that there's a tick box to override the global user name and email settings, which were different from my Assembla login.

MisterA
  • 43
  • 6
0

The same error (Windows, Git Bash command line, Visual Studio, bitbucket). Using https (not ssh) which should prompt for login credentials but instead errors (likely because my bitbucket credentials changed):

$ git pull origin master
fatal: Authentication failed for 'https://bitbucket.../my_git_project.git'
$ git config -l
...
credential.helper=manager
...

$ git config --global --unset credential.helper
$ git config --system --unset credential.helper

git pull now prompted for username/password prompts.

Vladislav Povorozniuc
  • 2,149
  • 25
  • 26
0

I was having a similar problem in Visual Studio for Mac 2022. It was my first time installing VS on my Mac and attempting to clone a repository to local, and the first time I tried to do so I mistakenly entered my password instead of my Personal Access Token. I fixed it by going to Keychain Access, searching for "github," selecting the one with the time that corresponded to when I had tried to clone the repo, and changing the password to my PAT. The next time I attempted to clone the repo, VS asked me if it could use the item within Keychain Access, and I granted permission and it worked.

Relevant GitHub docs: https://docs.github.com/en/get-started/getting-started-with-git/updating-credentials-from-the-macos-keychain

Miri ST
  • 1
  • 1