Live data from Hacker News

How I configure my Git identities

benji.dog

41–50 of 113 posts

Re: How I configure my Git identities

#41
> Note: I've had this post drafted for 3 YEARS!!! It's finally time to publish it.

I suddenly felt a deep connection with the author. It is not only me.

I promise you, my dear drafts, that one day, I will set you free to see the world!

Re: How I configure my Git identities

#42
One even-better approach IMHO

Just keep a .gitconfig in your HOME with aliases for your identities. Then just after initializing/cloning the repo do git config-company or git config-personal

    er453r@r7:~$ cat ~/.gitconfig 
    [user]
        useConfigOnly = true
    [alias]
        config-personal = !echo CONFIG-PERSONAL && \
            git config --local user.email 'personal@email.com' && \
            git config --local user.name 'personal' && \
            git config --local core.sshCommand 'ssh -i ~/.ssh/id_rsa_personal'
        config-company = !echo OLD CONFIG-COMPANY && \
            git config --local user.email 'official@comapny.io' && \
            git config --local user.name 'Name Surname' && \
            git config --local core.sshCommand 'ssh -i ~/.ssh/id_rsa_company'

Re: How I configure my Git identities

#43
post #14

Is there a risk with not using different keys for work and personal? The private bits are all in the same place: if one is compromised, so are the rest.

There is also a risk using the same machine for work and personal. I’d address that first.

Re: How I configure my Git identities

#44
post #37

Why have multiple git identities in the same machine? I use a single different key with each machine and that's it.

I use a unique account with every distinct git org / github org that I interact with.

Even if I'm in my work profile and I need to do something in an org called `acmecorp`, I will create @acmecorp-identifier to do that.

This is just a very long experience...

* Security policies for work things have a blast radius of just that employer

* OSS things have a lifetime beyond the life of an employment / contract

* Source control elsewhere (GitHub / GitLab / Bitbucket / Gitea / Forgejo / etc) all has a local blast radius, and if a provider / org forces changes (roll your keys!) then the impact is limited to just that provider

* When something changes ownership (i.e. an org), the impact to me is low

It seems much more sane.

I think of a single git identity across multiple orgs as a bit of a smell.

Re: How I configure my Git identities

#45
I love that Rek drew the image on your about page. I knew I recognized their work as soon as I saw it.

Based on that and your 1.44MB Club, you might find Neat CSS interesting. :P

https://neat.joeldare.com

My Neat CSS websites will almost always fit on a floppy and I have a case of old floppies right here in my closet. The Neat CSS home page is only about 12k. Things get bigger when you start adding images, of course.

Re: How I configure my Git identities

#48
I always strongly advise consultants to use a separate machine for work, or at the very least a separate OS user.

You’re risking putting yourself in a whole lot of trouble by using a personal machine for work.

Re: How I configure my Git identities

#49

Thank you for this! I have exactly the same problem and was waiting for the solution to present itself, which it now has. Aside: I use NixOS with home-manager (on linux and mac), which makes this trivial [1]. Added the following lines to my home-manager config: programs.git = { enable = true; ... includes = [ { condition = "hasconfig:remote.*.url:git@github.com: /**"; contents = { user.email = " "; }; } ]; } [1]: htt…

That certainly looks less trivial than writing it directly in your .gitconfig file. It's the same condition and setting as what's in the article, but now with a build/templating stage and a new programming language to learn with unusual syntax.

Re: How I configure my Git identities

#50
I used to work at a startup with a character who would set his identity to be random fairytale-sounding nonsense, changing every day. So his commits on Monday would be attributed to Mr. Bunnymann, and Tuesday would be Doctor Funtime, etc.

It was super unhelpful when trying to do version control forensics. But if I'm being generous, I think maybe he was trying to remind everyone that anyone can put anything in their identity config, and we shouldn't trust whatever is in there for all that much.

Post reply on HN