Git on Windows & Github, authentication suddenly stopped working

I’m using Github 2FA and git on Windows with the Windows Credentials store credential helper. This can be configured with
git config --global credential.helper wincred

Couple of times git has suddenly started complaining “remote: Repository not found” when trying to do a pull on existing project. I haven’t figured out what is causing this, but the solution that works:

  1. Clear the existing credentials. This is done by starting up Windows “credential manager” just type this to “Run… ” or find it via Control panel (this is part of Windows). Look for github related things and remove them
  2. After this, git should ask again for your username when you try to do an operation that requires authentication. With two factor authentication you can’t just enter the username and password. Instead of password you need to use “personal access token” which can be generated on Github web pages. Click your profile icon and selected “Personal access tokens” from the menu on the left. Generate either a new token or reset the existing one so that you get access to the token which is a hex string.
  3. Login with your Github username and the access token. Once you have done this, you should see an entry for git:https://<username> on in the Windows Credentials Manager.