Search code examples
gitgithub

Trying to use Git Credential Manager (instead of SSH) to clone/push/pull, but get error "Permission denied (publickey)"


I used to use SSH to clone/push/pull my projects, but I heard nowadays I can use Git Credential Manager instead of SSH.

On a new computer, without configuring SSH, I installed Git Credential Manager. When I try to push/pull from my old repo, or clone a new repo, I expect an auth window to popup. However, I simply get "Permission denied (publickey)".

How do I configure Git Credential Manager on a new computer and use it instead of SSH?


Solution

  • After installing Git Credential Manager,

    • if you want to clone a repo, you should use the https url, not the git@xxx url that you used to use with ssh.
    • if you want to push/pull from within an old project folder where you used ssh before, you need to change the remote url from git@xxx to the https one.

    To see if your previous repo used the ssh remote:

    cd my-old-project
    git remote -v
    

    To change it to https:

    git remote set-url origin https://github.com/my_username/my-repo-name.git
    

    Then you can start working on it normally, for instance git fetch, and Git Credential Manager will handle the rest.