Maintaining multiple GitHub accounts with ease

mrprofessor

Rudra Narayan

Posted on May 2, 2019

Maintaining multiple GitHub accounts with ease

I recently left a huge IT corporation for a promising startup.I was asked to change my GitHub handler name as it was too cool(I think) for them.Well instead of changing I created another account using my company email.

Now I got a problem.Every day when I come home and start hacking around my own projects I had to manually set my username and email id in git config in order to reflect my contributions in the graph and most of the time I forget to do so.

So I created some aliases to toggle between my two handles.

# Set user 1 as current user
gitfirst() {
    git config --global user.email 'xxx.yyyy@gmail.com' && git config --global user.name 'mrprofessor'
    gituser
}

# Set user 2 as current user
gitsecond() {
    git config --global user.email 'zzzzz@corporation.com' && git config --global user.name 'rudrabot'
    gituser
}

# Print current user
gituser() {
    git config --global user.name && git config --global user.email
}

And that five minute I save every day from this hack..spends for...well I don't know.

Adios.

This post was originally published on rudra.dev

💖 💪 🙅 🚩
mrprofessor
Rudra Narayan

Posted on May 2, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related