DEV Community

voboda
voboda

Posted on

1 2

Multiple Github accounts conveniently

I use several github accounts, and wanted a way to use them without constantly tweaking remote urls and stuff for each repo.

The good news is at some point, it seems git started to traverse directories upwards, looking for .gitconfig files. So it makes it easy to setup several directories, each of which uses different credentials automatically.

So, for my voboda account on github:

mkdir ~/repos/voboda
cd ~/repos/voboda
Enter fullscreen mode Exit fullscreen mode

And there I added a .gitconfig file containing:

[core]
    sshCommand = ssh -i ~/.ssh/id_rsa_voboda
[user]
    name = Voboda
    email = voboda@mygithubemail.com
Enter fullscreen mode Exit fullscreen mode

Now, anything I need to work on in my voboda account, I just clone that under the ~/repos/voboda directory. For example ~/repos/voboda/onelineforyourmind and ~/repos/voboda/underlinery. Both will use the above user information automatically. That specific ssh command references the ssh key I setup for my voboda github account.

Sidenote: separate ssh keys

On Linux, I setup that ssh key using ssh-keygen -f id_rsa_voboda and then copying the 2 outputted keyfiles to my ~.ssh directory.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay