Featured image of post 複数githubアカウントの管理

複数githubアカウントの管理

目次

背景

  • 毎回迷うのでメモをのこす
  • この3段階が一番キレイ

~/.gitconfig

これはdotfilesとかで管理されるglobalなgitignore。

1
2
[include]
  path = ~/.gitconfig.local

~/.gitconfig.local

これはdotfilesでは管理しないローカルなgitignore。

1
2
[includeIf "gitdir:/media/mike/xxx/"]
  path = ~/.gitconfig.xxx

この例では、あるmediaのxxx以下のgitのフォルダは、gitconfig.xxxを使用するという意味。

~/.gitconfig.xxx

そのある専用のフォルダで使われるgitconfig。

1
2
3
4
5
6
7
[user]
  name = xxx_hoge
  email = xxx@hoge
[commit]
  gpgsign = false
[core]
  sshCommand = ssh -i ~/.ssh/id_xxx_rsa -o IdentitiesOnly=yes

gpgはoffにしたり、usernameを変えたり、sshの設定を入れ替えたりしている。

テスト

その特定のフォルダの中でちゃんとworkしているかのテストは以下になる。

1
2
3
4
5
6
7
cd /medi/mike/xxx 

git config --get user.name
xxx_hoge

git config --get user.email
xxx@hoge

まとめ

がんばれ!ゴエモン!

Built with Hugo
テーマ StackJimmy によって設計されています。