体調不良のため長らくお休みしていました、過去をさかのぼって更新していきます。

HEXOでPlease make sure you have the correct access rights and the repository exists.と出てデプロイできない対処法

[PR] 記事内には広告が含まれています。

静的サイトジェネレーターHexo で github にデプロイしようとしてもエラーでできない場合の対処法です。

Please make sure you have the correct access rights and the repository exists.

HexoをGithubに hexo d でデプロイしようとしても、『Please make sure you have the correct access rights and the repository exists.(正当なアクセス権があるか、リポジトリがあるかどうか確認してください。)』というメッセージが出て何度やってもデプロイできませんでした。

何がおかしいのかわからなくて3時間くらいハマっていましたが、結論は公開鍵の設定でした。

公開鍵の発行

こちらを参考にさせていただきました。

gitでPlease make sure you have the correct access rights and the repository exists. が出た時の対処法 - Qiita
Git で以下のエラーが出た時にやったこと。 Bad owner or permissions on ~/.ssh/config fatal: Could not read from remote repository. Ple...

コマンドプロンプトの c\Users\ユーザー名> で実行

##sshKeyを作成する。
ssh-keygen -t rsa
-Generating public/private rsa key pair.

Enter file in which to save the key (C:\Users\username/.ssh/id_rsa):
##作成するディレクトリとファイル名を聞かれる。~/.ssh/id_rsaとなっていれば、なにも入力しないでenter。

Enter passphrase (empty for no passphrase):
##パスフレーズ(パスワードより長いキーワード)を登録するかと聞かれるので、特に必要なければ何も入力しないでenter。

Enter passphrase (empty for no passphrase):
##もう一度同じパスフレーズを入力してくださいと聞かれるので、また何も入力しないでenter。

Your identification has been saved in C:\Users\username/.ssh/id_rsa.
Your public key has been saved in C:\Users\username/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx@xxx
The key's randomart image is:
+---[RSA 2048]----+
|     省略        |
+----[SHA256]-----+
##以上で暗号鍵の生成完了

C\Users\ユーザー名 の中に .ssh というフォルダができるはず。

その中に、

id_rsa
id_rsa.pub
known_hosts

の3つのファイルができます。

※id_rsaは絶対誰にも見られないようにしてください!!!

id_rsa.pub のファイルをエディタで開きます。

これをコピーしておきます。

Github のリポジトリを開く

自分のGithubの該当するリポジトリのページを開きます。

上のタブのsettings を開きます。

左のメニューの『Deploy Keys』をクリック

Add deploy key ボタンを押します。

この画像はすでに公開鍵が設定されています。

↓Keyの部分にコピーしておいた公開鍵を貼り付けます。タイトルは何でもいいです。

Allow write access にチェックを入れるのを忘れずに。

もし間違えたらDeleteで消して入れなおせば良いです。

fatal: Not a git repository (or any of the parent directories): .gitpush declined due to email privacy restrictions というエラーの場合

こちらを参考にさせていただきました。

GitHub でエラーが出た時(Not a git repository) - Qiita
先日GitHubを使ってgit cloneで cloneした後、git pushしようとしたらとあるエラーが出ました。 以下のようなエラーです。 fatal: Not a git repository (or any of the ...

メールアドレスを登録します。

Githubのページに行って、ユーザーのSettingsのページを開き、左のメニューからEmails を開きます。

Keep my email addresses private のチェックを外してください。

そしてコマンドプロンプトから以下のように打ってEnterします。

git config --global user.email "email@example.com"

もちろん、メールアドレスはGithubに登録したメールアドレスで。

デプロイ成功!

これで 無事デプロイできました~~!