One-time setup for managing **two GitHub accounts** (personal + work) on the same machine using SSH keys. Covers generating unique SSH keys per account, adding them to the SSH agent, uploading public keys to GitHub, configuring the `~/.ssh/config` file for host aliasing, and setting up directory-based automatic user switching via nested `.gitconfig` files — so Git auto-detects which account to use based on which folder you're working in.
Open terminal and navigate to ~/.ssh
Generate SSH Key — Personal Account
Generate SSH Key — Work Account
Start the SSH Agent
Add Personal SSH Key to Agent
Add Work SSH Key to Agent
Copy Personal Public Key
Add Personal Key to GitHub Account
Add Host Entries to Config File
Test SSH Connections
Create Folder Structure
Create Personal .gitconfig
Create Work .gitconfig
Update Global .gitconfig with includeIf Rules
Clone Repos with Correct SSH Host Alias
Set Remote URL on Existing Repos
Verify Correct User is Active
One-time setup for managing **two GitHub accounts** (personal + work) on the same machine using SSH keys. Covers generating unique SSH keys per account, adding them to the SSH agent, uploading public keys to GitHub, configuring the `~/.ssh/config` file for host aliasing, and setting up directory-based automatic user switching via nested `.gitconfig` files — so Git auto-detects which account to use based on which folder you're working in.