Scenario: You have two different Git identities (i.e. ssh key, name, email, etc) on the
same machine, e.g. one for work and one for personal projects. The projects live in
separate folders.
Possible solution: Use conditional includes in your Git config.
What does this look like? The file structure looks like:
$ tree
/home/user/
├── .gitconfig
└── projects
├── personal
└── work
└── .gitconfig
The two .gitconfig files look like:
$ cat /home/user/.gitconfig
[user]
name = Hacker Name
email = hacker@example.com
[core]
editor = vim
[includeIf "gitdir:~/projects/work/"]
path = ~/projects/work/.gitconfig
$ cat /home/user/projects/work/.gitconfig
[core]
sshCommand = ssh -i ~/.ssh/other_key -F /dev/null
[user]
email = work@example.com
name = Work Name