Skip to main content

Managing Multiple Git Configurations

·1 min·

Suppose that you have a full time job at Amazon, and you want to separate your git commit emails from Amazon and your personal projects.

Setting up ~/.gitconfig

$ touch ~/.gitconfig

For our personal projects, we will use the ~/.gitconfig file with the following content:

  name = James Banned
  email =
[includeIf "gitdir:~/Work/"]
  path = ~/

The includeIf basically means that include this config if I’m inside the ~/Work/ directory.

Now, let’s create the ~/ so git would read that config every time we are working on our work related projects

$ touch ~/

Copy the following to the newly created file:

  email =

Now, this will use email when doing a

$ pwd
$ git commit -m "Update"
[master 5213482] Update
 1 file changed, 2 insertions(+)


$ git log

commit 52134828eab8b1dbb79ff5987aca2cdc373222e8 (HEAD -> master, origin/master)
Author: James Banned <>
Date:   Sat May 16 19:34:43 2020 +0800


Also, take note, we didn’t specify the name key here since git will use the values specified in ~/.gitconfig which, in this case, is James Banned.

Of course, we can add other configurations aside from email such as signingkey, custom aliases, and anything you valid that you can put inside a git config file.