When using a single computer for multiple categories of development (personal,
work, etc), there is often a need to set a specific user.email
value for each
repository cloned depending on the use. For example, it’d make sense to use your
work email for repositories cloned for work while you’d use your personal email
for you own projects.
Without the following setup, it’s very easy to forget to override your
user.email
at a repository level and end up committing to one or the other
with the wrong email attached. Though not the end of the world, I can imagine
your company, coworkers, and security department would prefer to see your work
email attached to all commits instead of a random Gmail account.
With the following in place, you’ll never forget to have the correct
user.email
set again!
Note: The following only works if you split up your repository clones within dedicated folders…which is probably better than mixing professional and personal repository together anyways.
.
├── personal
│ ├── repo1
│ └── repo2
└── work
├── repo1
└── repo2
In your main ~/.gitconfig
:
|
|
Now in ~/.gitconfig_work.inc
you can set your work specific information
|
|
With those configs, now any Git interaction within ~/Development/work/**
will be done with user.email
set to [email protected]
. No need for any local Git
config overrides ever again to set common settings for work vs personal
repositories.