複数のGitHubアカウントを1台のPCで使い分ける設定方法
更新日:2025/01/24

主な設定手順
- サブアカウント用のSSH鍵を生成
cd ~/.ssh
ssh-keygen -f id_rsa_private
- .ssh/configファイルの設定
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
Host github.private
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_private
- gitconfigの設定
# ~/.gitconfig_private
[user]
name = サブアカウント名
email = サブアカウントのメール
# ~/.gitconfig に追加
[includeIf "gitdir:~/private/"]
path = ~/.gitconfig_private
- 接続確認
ssh -T github.private
- リモートリポジトリの追加
git remote add origin github.private:username/repo.git
この設定により、~/private/
ディレクトリ以下では自動的にサブアカウントが使用されます。
https://zenn.dev/taichifukumoto/articles/how-to-use-multiple-github-accounts

-
検索
(例) debug search etc.. -
カテゴリー
新規記事
SEOサンプル記事
話題のキーワードから探す