ディレクトリごとに git の設定を切り替えたい

いっこまえの記事Google Cloud SDKの設定を切り替えたいと同じような話。git リポジトリごとにメールアドレスを切り替えたい、という場合の設定。

.gitconfig

[user]
    name = Shin Ise
    email = personal@example.com
(略)
[includeIf "gitdir:~/Working/my_company/"]
    path = ~/.gitconfig_my_company

includeIf に指定するディレクトリは、末尾に / つけないとうまく切り替わらない。

.gitconfig_my_company

[user]
    email = my_company@example.com