mariusv.com

Watch as I awkwardly stumble through life

Setup multiple git identities

Posted by Marius Voila on May 18, 2020 in London, U.K . — 0 comments This post contains 199 words

Working on many projects across multiple identities can be difficult to manage. So here is a simple solution to do a per-directory global git configuration.

In .gitconfig, you say:

    [user]
        name = Me Myself
        email = personal@example.com
        signingkey = D34DB44F

    [includeIf "gitdir:~/src/github.com/work_org/"]
        path = ~/.gitconfig_work

Then in ~/.gitconfig_work:

    [user]
        name = Me Myself
        email = work@example.com
        signingkey = D34DC0D4
    
    [core]
        sshCommand = ssh -i ~/.ssh/work_ed25519

I like this way better, because I don’t need to remember to specify per-project config, as long I put them in the right directory :-)

WARNING

While this works great if you are using your personal computer to do work. But if you use your employer issued computer to do personal hobby project, then please be very careful. In 90%+ of the cases your contract with your employer have the clause saying (please review your contract to clarify) that they own copyright of all your work while you are under the contract even if it’s outside of working hours or on the weekend, with a few exceptions, and using employer equipment (employer issued computer) nullify one of the biggest exceptions.