Live data from Hacker News

Conditional Git Configuration

blog.scottlowe.org

11–20 of 73 posts

Re: Conditional Git Configuration

#12
You can also configure multiple ssh keys through Github subdomains in your ssh conf file. While github ignores the subdomain your ssh-client will pick the corresponding ssh key bas d on the used subdomain in your repo url.

Re: Conditional Git Configuration

#14
post #9

Oh nice, this will remove an annoyance in my dotfiles repo by letting me share my gitconfig between 3 different configurations (home linux amd64 box, work macOS arm64, client macOS arm64) Thank you for sharing it!

I just have a "config-private" file that I include in my main config, but I ignore it in the dotfiles repo. Git will ignore any included file if it does not exist. That lets me customize things locally without checking work details into version control.

That's a neat way of doing it, I will do the same, thank you!

Re: Conditional Git Configuration

#18

You can also configure multiple ssh keys through Github subdomains in your ssh conf file. While github ignores the subdomain your ssh-client will pick the corresponding ssh key bas d on the used subdomain in your repo url.

So subdomains can be arbitrary and you just manually add them when performing git clone? Will then git push/pull/etc automatically use the fake subdomain you like for this repository?

Re: Conditional Git Configuration

#19
post #8

Nice. For years I've been using [direnv]( https://direnv.net/ ) for this, setting environment variables which git picks up. This looks like a more feature complete equivalent, although to be honest I only really need switching of committer email and the SSH key used.

You don’t need for config for the SSH piece as it defers to SSH’s own config for it.
Post reply on HN