Some time ago I’ve looked over my current company repositories. Surprisingly there was a lot of commits with emails that are not company ones. Instead of those - a lot of gmail.com, outlook.com and other free email providers!
That looks a bit unprofessional, isn’t it? Even if we do some freelance gigs - we probably want to put nicer email than private one used for social websites. And if, for some reason, we’re forced to use company email - we need to be sure that it will be used!
So, what we can do to make it better? Just configure it
with couple lines of code ;-) Let’s assume that all our work-related
stuff will live in
~/work folder and all other is personal. So,
let’s start with a simple
# ~/.gitconfig [user] name = Johny Mnemonic email = email@example.com [includeIf "gitdir:~/work/"] path = ~/work/.gitconfig
Configuration in user section will be default one. We will overwrite it in other configuration files, like in folders with work.
Let’s then create an additional configuration for work, just in our work folder:
# ~/work/.gitconfig [user] email = firstname.lastname@example.org
We want to put our name in commits, yep? So only one thing that we overwrite will be the email address. Instead of private one, there will be company email.
And that’s it. Now all repositories, that didn’t have set up individual user settings, will use ones that are based on the folder, e.g.:
~/work/super-duperwill use work configuration,
~/project/my-websitewill use private (default) one.
I hope that “short writeup” will help somebody in some way. :-) Also - did you have any comments? Drop me a line on Twitter!