Managing multiple Git identities
I have multiple Git identities (personal/school/work), and having to manually specify which to use each time quickly got tedious. Luckily, Git has conditional includes.
Initially, I used gitdir/i
to include the relevant configuration file
based on the repository’s case-insensitive path:
However, since Git 2.36.0 I use a combination of hasconfig:remote.*.url
and
SSH’s Host
keyword to include based on the remote’s URL:
With this, using an identity is just a matter of
git clone github-personal:…
.