Skip to content

Sometimes you need to maintain different projects under different names.

Consider two projects:

Here's how we're gonna solve the problem.

  1. Have all of your working projects in one directory (e.g. ~/work/), and any other project in another ones.
  2. Open the ~/.gitconfig in your favorite editor. Add two sections inside of it:
[include]
	path = ~/.git-personal.conf

[includeIf "gitdir:~/work/"]
	path = ~/.git-work.conf
  1. Create two files - ~/.git-personal.conf and ~/.git-work.conf

.git-personal.conf will have your personal author for your own projects.

[user]
	name = Chuck E. Cheese
	email = chucky@mail.me
	signingkey = XXXXXXXXXXXXXXXX

~/.git-work.conf will contain the git author for your work projects.

[user]
	name = Charleston Entertainment Cheese The Third
	email = c.e.cheese@serious-it-company.com
	signingkey = YYYYYYYYYYYYYYYY

Now, if you check git config --global user.email in ~/work/* directory and any other directories, you will get different emails.

Keep in mind that, if you will try to git clone another project into the ~/work directory, it may throw an error, because git will think that you're cloning as a personal git author.