Git error: “Please make sure you have the correct access rights and the repository exists”

后端 未结 27 992
面向向阳花
面向向阳花 2020-12-12 14:49

I am using TortoiseGit on Windows. When I am trying to Clone from the context menu of the standard Windows Explorer, I get this error:

Please make sur

27条回答
  •  醉酒成梦
    2020-12-12 15:12

    I'm using Ubuntu

    after reading many of answers, none of them can solve the problem, even if I already added SSH key to my git account, and try test it using ssh -T git@gitlab.com and it said Welcome , but it still kept telling me that I don't have access rights. Then I found the reason:

    Normally if you're not root user, it will require you to run with sudo for every git command.

    when running sudo git clone (for example). it will be executed under root permission, but accidentally when create SSH key I run it as normal user and I save the key in ~/.ssh/id_rsa, it resolves the absolute path /home/username/.ssh/id_rsa. And when doing sudo git clone ... it looks for SSH key in /root/.ssh/id_rsa

    Why I can sure about this. To see where git looks for your SSH key. Run this command: sudo GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git clone . It will show you where it looks for your SSH key.

    So the SOLUTION I suggest is:

    Re-creating your SSH key (follow this instruction), BUT run sudo su at the very first step, then you'll should be fine.

提交回复
热议问题