Saturday, August 13, 2016

Windows Git/GitHub Results in "Error Repository Not Found" or Denied Public Key Solution

I spent a good chunk of a day to resolve issues related to "Error Repository Not Found" or even got Permission denied (publickey) type error messages.

This issue happened suddenly on my Git environment integrated with IntelliJ Ultimate. While investigating this, I made things even worse and Git was totally denied including using SSH.

Along the way, I also tried Two Factor authentication on GitHub, and eventually got that to work both in IntelliJ and also with SourceTree.

The following sequence of events finally have fixed the issue.

If You've Tried These Already, then You Have the Same Problem as I Had.

  • Instead of trying you tried Note that this would not work if your Windows Credentials already has cached your user name and password.
  • You tried to change to the SSH URL
  • You've even tried to generate a new SSH key
  • You've even loaded the SSH key via pagent.exe
    • Note that SSH issue is a separate issue, so in this article I will stick with getting you back up and going with https (including using the Two-Factor authentication.)

1. Check the Windows Credentials to Remove Any Git Related

  • Open the Start menu and type in "Credential Manager"  This will open the Windows Credential Manager. This is basically the same thing as "Mac OS Keychain" in fact, if you are on the Mac, you would want to check there. Check and remove all Git related credentials, this is the most likely cause if you see https:// Repository not Found issue. 
  • Now try your Git access and see this will issue a new username and password prompt.

2. Last Resort: Completely Remove Your Git and Re-Install it Directly

  • Be sure you have done Step 1.
  • For this does not use chocolaty. If you did already, first try the uninstall via "choco uninstall git".
  • Go to the Program and Features and remove any installations of Git
  • Go to C:\Program Files\Git or likewise and manually delete all remnants of Git
  • Download and install from the Git Web Site. 
  • Check your~/.gitconfig file to make sure nothing strange is there. Also, I would check in your local Git repos./.git/config file for URLs pointing to the repo.  (Note, you can type in cd ~ if you are using PowerShell, if anything else, that's one big attraction of using PowerShell to be able to cd to ~/Downloads and ~/Desktop)  give it a shot I will post an article about PowerShell Essential Survival Guide next.
If You Have Activated Two-Factor Authentication...

The password field you provide should not be your interactive login password, but you should generate a Personal Access Token on your GitHub account  Note that you only see the token once after you generate it, so have a Notepad ready to temporarily copy it.

Next launch your Git UI app like SourceTree and do some operation like Fetch, this should prompt you again for the password. Use the token you have just copied in the password field and let the credential to save. This will wind up in the Windows Credentials Manager so next time you change this, you would want to do Step 1 as above.

No comments: