How to Set Up Work and Personal Git Profiles

Tired of accidentally committing to work repos with your personal email? Here’s how to automatically use the right Git profile based on where your repositories live. 1. Generate SSH Keys Create separate keys for each account: # Work key ssh-keygen -t ed25519 -C "work@company.com" -f ~/.ssh/id_ed25519_work # Personal key ssh-keygen -t ed25519 -C "personal@gmail.com" -f ~/.ssh/id_ed25519_personal 2. Configure SSH Hosts Edit ~/.ssh/config: # Work GitHub Host github-work HostName github.com User git IdentityFile ~/.ssh/id_ed25519_work IdentitiesOnly yes # Personal GitHub (default) Host github.com HostName github.com User git IdentityFile ~/.ssh/id_ed25519_personal IdentitiesOnly yes 3. Set Up Git Profiles Global config (~/.gitconfig): ...

July 25, 2025