Date Category tech

I – like many people, I assume – have a personal email address and a work email address. When I’m working in any particular git repository, one of the addresses will be more appropriate than the other. With git, you can configure your email address pretty easily on a per-repository basis:

git config user.email "my.email@example.com"

Unfortunately, what often happens is I forget to do this, and then one or more of my commits to the repository will have the wrong email address as the author. It was enough of an annoyance that I hacked together a git wrapper script that forces you to confirm your name and email address on every git clone or git init. (It’s also written sort of generally, so you could adapt it to hook into other git commands as well.)

For example:

$ git clone git://github.com/rails/rails
Cloning into 'rails'...
remote: Counting objects: ...
remote: Compressing objects: 100% ...
remote: Total...
Resolving objects...
Resolving deltas...
--
Configuring author for this repository...
Author name: [Mike Mueller]
Email address: [mike@example_home.com] mike@example_work.com
  [rails] git config user.email "mike@example_work.com"

That’s it! If a value is correct, you can simply hit enter (as I did with my name), and if a value is incorrect, just type the new value (as I did for my email). These are now configured properly inside the repository (does not affect your global git configuration).