As I was working on a project, GitHub Desktop bombarded me with this login dialog:
The user it showed made no sense and I could push my local commits to the remote repository for the project I worked on. What was wrong with this Git client?
Should this happen to you, click on Help / Show logs in Explorer:
This opens up Explorer and you can open the newest log file. Inside the log file you should find one or more entries like this one:
*** error: [ui]
git -c credential.helper= fetch --progress --prune origin
exited with an unexpected code: 128.
stderr:
Permission denied, please try again.
Permission denied, please try again.
****@vs-ssh.visualstudio.com: Permission denied (password,publickey).
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.(The error was parsed as 2: Authentication failed. Some common reasons include:
– You are not logged in to your account: see File > Options.
– You may need to log out and log back in to refresh your token.
– You do not have permission to access this repository.
– The repository is archived on GitHub. Check the repository settings to confirm you are still permitted to push commits.
– If you use SSH authentication, check that your key is added to the ssh-agent and associated with your account.
– If you use SSH authentication, ensure the host key verification passes for your repository hosting service.
– If you used username / password authentication, you might need to use a Personal Access Token instead of your account password. Check the documentation of your repository hosting service.)
*** info: [ui] Executing fetch: git -c credential.helper= fetch –progress –prune origin (took 1.181s)
*** info: [ui] Executing fetch: git -c credential.helper= fetch –progress –prune origin (took 1.128s)
*** error: [ui]git -c credential.helper= fetch --progress --prune origin
exited with an unexpected code: 128.
stderr:
fatal: Authentication failed for ‘https://dev.azure.com/***/_git/myRepo/’
In the top you should see the username / e-mail from the error dialog and at the end you will find the repository that GitHub Desktop cannot connect to.
Unfortunately, the second part with the repository name is not part of every message for a failed authentication. You may need to enter your password multiple times until the credential helper of Git will be kind enough to tell you what repository it can’t access.
If you cannot match the problem to a repository, open the folder containing your Git repositories in the command line. Change to WSL and run this command:
1 |
for d in ./*; do (cd "$d" && pwd && git -c credential.helper= fetch --progress --prune origin); done |
This iterates through your project directories and runs the call to Git’s credential helper explicitly. Whenever it asks you for your credentials, you can scroll up a few lines and see the path of the repository it works on.
Enter the correct credentials or remove the working copy of the repository if you no longer need it. Both will stop the problem in GitHub Desktop for good.