スポンサーリンク
Contents
~/.ssh/configの設定
Host github_p
HostName github.com
User git
IdentityFile ~/.ssh/pv-github
IdentitiesOnly yes
UseKeychain yes
AddKeysToAgent yes
Host github_w
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
UseKeychain yes
AddKeysToAgent yes
プライベート用がgithub_p
仕事用がgithub_w
グローバルのユーザ情報を設定しない
グローバルのユーザ情報を設定している場合は設定を消す
git config --global --unset user.name
git config --global --unset user.email
~/.gitconfig
グローバルのユーザ情報が設定されていなければOK
[user]
# nameが設定されていないことを確認
# emailが設定されていないことを確認
ローカルで user.name, user.email, url..insteadOfの設定をする
cd 個人用既存のリポジトリパス
git config --local user.name "個人ユーザ名"
git config --local user.email "個人メールアドレス"
# url."ssh_configで設定したHostの値".insteadOf という形式にします
git config --local url."github_p".insteadOf "git@github.com"
cd 仕事用既存のリポジトリパス
git config --local user.name "仕事ユーザ名"
git config --local user.email "仕事メールアドレス"
# url."ssh_configで設定したHostの値".insteadOf という形式にします
git config --local url."github_w".insteadOf "git@github.com"
.git/config
[user]
user = "個人ユーザ名"
email = "個人メールアドレス"
[url "github_p"]
insteadOf = "git@github.com"
参考サイト
スポンサーリンク