Gitconfig

Gitconfig is a interesting file when you are able to use an if statement based on the directory of a project. Below is my tree for projects that both define personal and professional configurations. This allows me

/Users/addlema
├── .sh.d
├── src
│   ├── git.worksite.com
│   └── github.com
├── .gitconfig
├── .gitconfig-personal
├── .gitconfig-work

In my $HOME/.gitconfig file I have the following:

[includeIf "gitdir:~/src/github.com/"]
	path = .gitconfig-personal
[includeIf "gitdir:~/src/git.worksite.com/"]
	path = .gitconfig-work

Then in my $HOME/.gitconfig-personal, I use the following content:

[user]
name = Aaron Addleman
email = [email protected]
signingkey = FCF6C3A2140015F9

[commit]
gpgSign = true

The other file of $HOME/.gitconfig-work shares the same name, but a different email address. This helps automatically set the Name and Email settings for git projects based on the top level directory they reside within.

Previous