Git Config


Here's a handy trick for using your preferred email address based on the directory context you're working in. This helps prevent accidentally committing to a Git repository with the wrong email address. Now work, personal, and freelance code commits always have the appropriate commit address.

In my home directory, I have ~/.gitconfig, the standard file for global options. Obviously there's the global default under [user]. The magic happens with [includeIf "…"]. Once I'm in one of those work directories, the path based configuration will override the global default!


    name = Travis Miller
    email =

[includeIf "gitdir:~/work/broco/"]
    path = /Users/tmiller/work/broco/.gitconfig
[includeIf "gitdir:~/work/gitlab/"]
    path = /Users/tmiller/work/gitlab/.gitconfig
[includeIf "gitdir:~/work/travismiller/"]
    path = /Users/tmiller/work/travismiller/.gitconfig
[includeIf "gitdir:~/work/underdogsystems/"]
    path = /Users/tmiller/work/underdogsystems/.gitconfig


    email =