Preventing unwanted git email leaking

Maybe you work on different git projects, on business, then at home for personal projects. In the past, as a convenience, I set my ~/.gitconfig to include my name and email like the following.

	name = "Shane A. Stillwell"
	email = ""

This is exactly what git wants you to do when it detects you haven’t set your name or email

*** Please tell me who you are.


  git config --global ""
  git config --global "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

So what’s the big deal? 

Now when you are working on a projects for work, or different clients, it will use the global name / email, but shoot, you didn’t mean to make that commit with your personal email, it was supposed to be your work email. Bummer, it’s now a permanent part of git log.

The solution 

Very simple. Open up your ~/.gitconfig and change your email to none. (I assume your name doesn’t change between projects)

	name = "Shane A. Stillwell"
	email = "(none)"

Now in each project, before you can commit you’ll be prompted like above, just remember NOT to use the --global flag, e.g. git config "". Now each git repo will have a correctly set email address and you’re less likely to leak personal emails into business projects.

Did this help you out? It took me a few days to piece together all this information together, I hope this saves you some time (who knows, maybe the future me will be thankful I wrote this down). Let me know your thoughts.