Could not read from remote repository

前端 未结 21 3289
北荒
北荒 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: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

提交回复
热议问题