LoginSignup
7
5

More than 1 year has passed since last update.

【Github】SourceTreeからGithubにプッシュができないときの対処法

Last updated at Posted at 2022-12-07

はじめに

今回は、私がGitを勉強していてSourceTreeとGithubを紐づけてプッシュを行おうとしたときに、エラー文が出てプッシュできなかったため、解決策を書き留めようと思います。

(Windows10での記事になります。)

問題

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)

いざSourceTreeでpushしようとしたとき上記のエラーが出ました。初めてpushする際に出るエラーのようです。こちらSourceTree上では解決できませんのでご注意を。

対処法

まずSourceTreeのツールである、plink.exeのパスを調べる必要があります。

Cドライブ→ユーザー→{あなたのユーザー名のファイル}→AppData→Local→SourceTree→app-{バージョン}→tools→putty

このputtyフォルダ内にplink.exeがあると思います。また、AppDataフォルダが見つからない場合は、エクスプローラー左上の【表示】から隠しフォルダのチェックを付けるようにしてください。
スクリーンショット 2022-12-07 153556.png

それでは、そのフォルダのパスをコピーして、(エクスプローラーのファイルのところをクリックするとパスが得られます。下図参照)

スクリーンショット 2022-12-07 153741.png

コマンドプロンプトを起動してこのディレクトリに移動していきます。

cd {コピーしたパス}

puttyフォルダに移動できたら下のように、コマンドを入力してください。

.\plink.exe -ssh -C -i "{ppkファイルのパス}" git@github.com

そうするとSourceTreeで出てきた一番最初に示したエラー文が出てきます。

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)

yと入力すると、Access grantedと表示されますので、それが表示されたら完了となります。

場合によっては実際にpushを行うと、「SSHエージェントを起動しますか?」という表示が出ますので「はい」を押してもらい、ppkファイルを指定していただければ完了となります。

おわりに

GithubとSourceTreeとの紐づけでエラーが生じてしまったので、対処法をまとめました。
分かりにくいかもしれませんが、参考になれば幸いです。
個人開発ばかりしていたため、Gitの勉強を全くしてこなかったのですが、もっと早く勉強しておけばよかった、、、という後悔が募ります(笑)

7
5
1

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
7
5