Git credential failures

Over the last couple of days at work, my Git started to play up: every time I tried to interact with the remote repo (for a fetch, push or pull), I got error messages like this:

Failed to erase credential: Element not found

fatal: Authentication failed for https://rhubarb.custard

This continued to happen after a machine restart, and affected everything from git-bash to Posh-git to SourceTree.

It turned out that I had Git Extensions installed, which includes a credential helper. I hadn't realised, but that helper was remembering my login for the Git repo, so I didn't need to enter it each time. Somehow, the helper had apparently got snarled up and wasn't working correctly.

It's enabled through the following lines in the .gitconfig file:

[credential]
  helper = !\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\"

I removed those lines from my .gitconfig and ran a fetch: I had to enter my credentials, but it worked! I then readded the same lines, and fetched again, and my Git was back working just as before.

Hopefully this might help someone else with the same problem - despite lots of search hits, there was no advice that referred to problems with an existing repo.