Folder specific git config

Having projects from various domains like work, private hobbies, and side projects may require different git configurations, including users, ssh keys, and specific settings. To manage this effectively, you can utilize both global and folder-specific git configurations.

Extending Global .gitconfig

If you have previously used git on your machine, you can access your global git configuration at ~/.gitconfig. Here’s how you can set up a folder-specific git configuration:

[user]
    email = [email protected]
    name = Philipp C. Baecker
[includeIf "gitdir:~/Development/forwork/"]
    path = ~/Development/forwork/.gitconfig

Creating Folder-Specific .gitconfig

Next, create a folder-specific git configuration at ~/Development/forwork/.gitconfig:

[user]
    email = [email protected]
    name = Philipp ForWork Baecker
[core]
    sshCommand = ssh -i ~/Development/forwork/sshkey

This setup allows git to use a different user and ssh key specifically for projects under ~/Development/forwork/. It ensures seamless management of multiple projects with distinct requirements.

To learn more about creating an ssh key, refer to this guide: Generate SSH Keys with ed25519