LoginSignup
20
11

More than 3 years have passed since last update.

GitHubでプルしようとしたらfatal: Could not read from remote repositoryになった話

Last updated at Posted at 2020-07-22

作業しながらメモしていたので若干間違いがあるかもしれません.

Pemssion Error

VScodeのgithistoryでリモートリポジトリからローカルリポジトリにプルしようとしたらPemssion Errorが発生.

スクリーンショット 2020-07-22 14.02.26.png

公開鍵の認証ができませんでしたということらしい.

Git: git@github.com: Permission denied (publickey).

GitHubにssh接続して認証すればいいのねってことで,

#ssh接続
ssh -T git@github.com

ってして認証したら

Git: packet_write_wait: Connection to <IP address> port 22: Broken pipe
fatal: Could not read from remote repository.

リモートリポジトリが読み込めないらしい.
ということでいろいろ調べてみたら以下の記事を発見した.

fatal: Could not read from remote repository. の落とし穴

プルの仕方が悪いのか?(確かに悪かった)と思ったのですが、プッシュもできないのでそうでもないみたい.
でよーく考えると...


リモートリポジトリの名前変更してた


何も考えていなかったですけどリモートリポジトリの名前を変えたり, プライベートリポジトリにしたりとGitHub上でいろいろ操作してました.
忘れてました.

git remote -v

で確認すると

origin  git@github.com:jamjamjam888/DOCI.git (fetch)
origin  git@github.com:jamjamjam888/DOCI.git (push)

となってました(github上でDOCI-projectに変更していた).

いったんリモートリポジトリを元に(DOCI)に戻して、改めてローカルからリモートリポジトリの名前を変更しました.

git remote set-url origin git@github.com:jamjamjam888/DOCI-project.git

リポジトリの名前を変更する

参考記事

-Gitのコマンドについて-

基本的なGitコマンドまとめ

-Permission Deniedについて-
Error: Permission denied (publickey)[公式ドキュメント]

ちなみに以下のコマンドで, キーが使用されていることを確認することもできる.
これでPermissionがうまくいっているか確認できる.

ssh -vT git@github.com

結果

#大量の処理
#:
#いけてる
>>>Authentication succeeded (publickey).

おまけ

2020/07/28追記
リポジトリを作ってコミットしても草が生えていないので確認するとレポジトリにユーザーネームとメールアドレスを登録する必要があるらしい.

そこで以下のコマンドで登録してみた.

git config –global user.name <ユーザ名>
git config --global user.email <メールアドレス>
20
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
11