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

后端 未结 27 917
面向向阳花
面向向阳花 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:11
    1. The first thing you may want to confirm is the internet connection. Though, internet issues mostly will say that the repo cannot be accessed.

    2. Ensure you have set up ssh both locally and on your github. See how

    3. Ensure you are using the ssh git remote. If you had cloned the https, just set the url to the ssh url, with this git command git remote set-url origin git@github.com:your-username/your-repo-name.git

    4. If you have set up ssh properly but it just stopped working, do the following:

      • eval "$(ssh-agent -s)"
      • ssh-add

      If you are still having the issue, check to ensure that you have not deleted the ssh from your github. In a case where the ssh has been deleted from github, you can add it back. Use pbcopy < ~/.ssh/id_rsa.pub to copy the ssh key and then go to your github ssh setting and add it.

    I will recommend you always use ssh. For most teams I've worked with, you can't access the repo (which are mostly private) except you use ssh. For a beginner, it may appear to be harder but later you'll find it quite easier and more secured.

    0 讨论(0)
  • 2020-12-12 15:11

    I had this problem, and i discover that my system was with wrong dns address. Verify your network and test with

    ssh -vvv git@bitbucket.org
    

    And read the output messages. If you see "You can use git or hg to connect to Bitbucket." , everything is ok.

    0 讨论(0)
  • 2020-12-12 15:12

    Github now uses a url scheme

    git remote set-url origin https://github.com/username/repository.git

    0 讨论(0)
  • 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 <my username>, 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 <SSH....> (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 <your repository in SSH>. 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.

    0 讨论(0)
  • 2020-12-12 15:12

    use your https origin instead of ssh url

    example:

    git remote add origin  https://gitlab.com/user/folder.git
    
    0 讨论(0)
  • 2020-12-12 15:17

    Switching to the use of https works. First switch to https rather than ssh keys. git remote set-url origin

    It will then request for the git username and password.

    0 讨论(0)
提交回复
热议问题