Live data from Hacker News

Conditional Git Configuration

blog.scottlowe.org

71–73 of 73 posts

Re: Conditional Git Configuration

#71
post #35
post #31

Earlier quoted context omitted.

You are basically just repeating what he said, but it doesn't answer my question. After all I'm not ssh-ing to GitHub directly, I'd use git, which will use ssh as a transport, and I don't know if git will use the subdomains I provide the way I think it should (my primary concern being to prevent GitHub from displaying 2 public keys for a single account, so that 3rd party cannot tell that it's most probably the same p…

I tested it myself, like `ssh git@rando.github.com` and that didn't work. That was my interpretation of the original comment. (reading it again, it seems like it was indeed saying what I typed below) It seems like the reply was saying instead you can do in your .ssh/config file Host work.github.com HostName github.com Host me.github.com HostName github.com (or just leave out the .github.com in the Host part) So `ssh…

Yes this is what they mean. I've use this setup in the past when for example I wanted to use different SSH keys for bitbucket, gitlab and github for example.

It works even for same hostname like I did here - https://github.com/hashhar/dotfiles-tmp/blob/master/ssh/.ssh...

Re: Conditional Git Configuration

#73
post #13

Can different .git-credentials files also be loaded conditionally? When one uses https access with multiple accounts....

~/.gitconfig:

    [credential]
        credentialStore = secretservice
        helper = /usr/local/bin/git-credential-libsecret
    [credential "https://github.com"]
          username = akdor1154
    [includeif "gitdir:~/src/mywork/"]
          path=~/src/mywork/.gitconfig
~/src/mywork/.gitconfig:

    [user]
        email = "12345+akdor1154-mywork@users.noreply.github.com"
        signingkey = ~/.ssh/id_rsa.mywork.private
    [credential "https://github.com"]
        username = akdor1154-mywork
The `username` is passed to the global secret helper and is thus used for it as part of the pick/prompt context for password. I'm using the libsecret helper but this works with any.
Post reply on HN