UnityのプロジェクトをGitHub, SourceTreeで管理
目的
UnityのプロジェクトをGitHubとSourceTreeで管理しようとしたらアクセス周りの話で色々問題が発生したので,対処法のメモ.
現状やったこと
リポジトリの作成
Unityでプロジェクトを作成(中身の変更はなし)
Unityでignoreするとよいらしいものをまとめた.gitignoreをダウンロード
SourceTreeにGitHubのアカウント追加
問題
SSHキーがうまく設定できてなくて,リモートリポジトリからプルしたり,プッシュしようとすると怒られが発生する.
例えば,pullしようとすると次のようなのが吐かれる.
git --no-optional-locks -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree fetch origin
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Completed with errors, see above
対処してみたこと
chatGPTにエラー投げてみた
次のような感じで反応が返ってきた.
この手順通りに進めてみた.
生成したSSHキーの名前は、デフォルトでは id_ed25519 という名前になります。このキーペアは .ssh ディレクトリに保存されます。
したがって、キーペアのファイル名は以下の通りです:
秘密鍵: ~/.ssh/id_ed25519
公開鍵: ~/.ssh/id_ed25519.pub
このファイル名は、SSHキーの生成時に変更しない限りデフォルトのままです。もし別の名前でキーを生成したい場合は、SSHキーの生成時に -f オプションを使用してファイル名を指定することができます。以下は例です:
javascriptCopy codessh-keygen -t ed25519 -C "your_email@example.com" -f ~/.ssh/my_custom_key
この場合、秘密鍵は ~/.ssh/my_custom_key に保存され、公開鍵は ~/.ssh/my_custom_key.pub に保存されます。
ただし、基本的にはデフォルトの id_ed25519 という名前を使用して問題ありません。もし別の名前を使用する場合でも、公開鍵は .pub 拡張子を持つファイルとなります。
この通りにやったらpullもpushも出来るようになった.
chatGPT様様.
この記事が気に入ったらサポートをしてみませんか?