Using Git with Multiple Email Addresses

Has this ever happened to you?

  • Gitlab commits are logged in your personal account but not on your work account (and vice versa) - but they seem to work correctly on your self-merged MRs.
  • Gitlab activity doesn't seem to log the days you're sure you've contributed code. and who is firefire199469 (and apparently this is your secret Gitlab). And why are you merging his commits?
  • Work Slack Gitlab notifications don't show your profile picture.

This is because you configured your git to use these user profiles globally.

# bash
$ git config --global ""
$ git config --global "Bob Ong"

Now you're always in all your commits on all projects.

To fix this, you can set your user profile on a git repository level.

# bash
$ cd $HOME/Projects/workproject
$ git config ""
$ git config "Jesse Panganiban"

$ cd $HOME/Projects/secretproject
$ git config ""
$ git config "Dude Dude"

You get the idea.

Show Comments

Get the latest posts delivered right to your inbox.