はじめに
- DeployKeyを登録しようとすると、Key is already in useとエラーになる。
- 同じ公開鍵は登録できないので、SSHとGITの設定変更で対処。
GitHub
リポジトリ作成
- リポジトリを作成する
SSH鍵の生成
.sshフォルダ
.ssh/config
Host 識別ホスト名 User git Port 22 HostName github.com IdentityFile ~/.ssh/秘密鍵ファイル名 TCPKeepAlive yes IdentitiesOnly yes
ローカルにクローン
git clone https://github.com/ユーザ名/リポジトリ名.git
GitのリモートURL設定
現状確認
git remote get-url origin
変更
git remote set-url origin git@識別ホスト名:ユーザ名/リポジトリ名.git
.git/config
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = git@識別ホスト名:ユーザ名/リポジトリ名.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "main"] remote = origin merge = refs/heads/master [user] email = ユーザのメールアドレス name = ユーザ名
動作確認
git push