Last Updated: November 27, 2020
· alexvpopov

How to use your personal email for personal projects and company email for company projects


Most companies require their employees to use their company email when working on company projects. At the same time, most people prefer to use their personal email for projects they work on in their free time. If one puts their personal email in ~/.gitconfig, they'll have to change this setting for every company project they work on or vice versa. This is annoying. Here's how to make Git always pick the right email:

  • Put your personal email in ~/.gitconfig:
  name = Your Name
  email =
  • Inside your root directory, create a directory for all your company's projects:
mkdir ~/ACME
  • Inside it, create another .gitconfig file and add your company email there:
touch ~/ACME/.gitconfig


  email =
  • At the end of ~/.gitconfig add:
[includeIf "gitdir:~/ACME/"]
  path = ~/ACME/.gitconfig

From now on, any project inside ~/ACME will use and projects in other directories -