Could not read from remote repository

前端 未结 21 3134
北荒
北荒 2020-12-15 02:30

I have received the following error multiple times:

Could not read remote repository. Please make sure you have the correct access rights and the repo

相关标签:
21条回答
  • 2020-12-15 03:11

    On Windows open file:
    C:\Users\<USER_NAME>\.ssh\config

    You should have your host defined in the "config" file:

    host gitlab.com
     HostName gitlab.com
     IdentityFile ~/.ssh/id_rsa_user_private_key
    
    host bitbucket.org
     HostName bitbucket.org
     IdentityFile ~/.ssh/id_rsa_user_private_key
    
    host github.com
     HostName github.com
     IdentityFile ~/.ssh/id_rsa_user_private_key
    
    0 讨论(0)
  • 2020-12-15 03:12

    Hi my problem was that my client did not ask if I recognized the key. Opening a terminal and doing ssh -T git@github.com worked. The response in the terminal asked if I wanted to add the key, I said yes and after that, my client worked fine

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

    Assuming you have done the proper SSH keys configuration according to github's instructions it might be a problem of pull with https and later pushing with git+ssh

    to make it more clear

    if you have used https to pull

    git pull https://github.com/user/repo.git
    

    then you have changed remote URL

    git remote set-url origin git+ssh://github.com/user/repo.git
    

    and tried to push after some changes and commits

    git push origin master
    

    you might get this error it happened to me

    erase the local repository and re-clone using git+ssh

    git pull git+ssh://github.com/user/repo.git
    

    and now your push should work

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

    I had the same issue with Pycharm on Ubuntu the solution is to use https instead of SSH for example : https://github.com/Bedo1212/myrepo.git

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

    In addition to setting the identity files in the ssh config, I also had to set the git remote to the right user - complete solution in https://www.keybits.net/post/automatically-use-correct-ssh-key-for-remote-git-repo/

    vi ~/.ssh/config
    Host github.com-myuser
      HostName github.com
      User git
      IdentityFile ~/.ssh/mykey
    

    I made sure I had this identity file loaded with ssh-add -l

    ssh-add -l
    4096 SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX mykey (RSA)
    

    Then I set my remote to include the right user

    git remote set-url origin git@github.com-myuser:myuser/myrepo.git
    

    Then the push worked

    git push -u origin master
    Enumerating objects: 146, done.
    Counting objects: 100% (146/146), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (144/144), done.
    Writing objects: 100% (146/146), 9.71 MiB | 7.48 MiB/s, done.
    Total 146 (delta 10), reused 0 (delta 0)
    remote: Resolving deltas: 100% (10/10), done.
    To git@github.com-myuser:myuser/myrepo.git
     * [new branch]      master -> master
    

    Voila

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

    If you're using SSH, make sure you're using a network that allows SSH. Most public networks allow only HTTP(S) traffic.

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