LoginSignup
5
8

More than 3 years have passed since last update.

GitHub と GitLab で Git config を切り替えたい

Last updated at Posted at 2019-07-28

設定方法

ディレクトリごとに読み込む設定ファイルを分岐させます。

/Users/iris/Documents/repos/
├── github.com
└── gitlab.com

github.com 以下には GitHub のリポジトリ、gitlab.com 以下には GitLab のリポジトリが配置されている状態です。

gitlab.com 以下にいる時だけ ~/.dotfiles/git/gitconfig.gitlab を読み込むようにして user.email を GitLab に登録した Email で上書きします。

.gitconfig
[user]
    name = peaceiris
    email = 30958501+peaceiris@users.noreply.github.com

[includeIf "gitdir:~/Documents/repos/gitlab.com/"]
    path = ~/.dotfiles/git/gitconfig.gitlab
~/.dotfiles/git/gitconfig.gitlab
[user]
    email = my-gitlab-email@gmail.com

includeIf について

以下を参照した。

5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8