cd ~/.ssh
ssh-keygen -t rsa -C "my@personal" -f "github-personal"
ssh-keygen -t rsa -C "my@work" -f "github-work"ssh-add --apple-use-keychain ~/.ssh/github-personal
ssh-add --apple-use-keychain ~/.ssh/github-workCopy public keys to clipboard:
pbcopy < ~/.ssh/github-personal.pub # Add to personal GitHub account
pbcopy < ~/.ssh/github-work.pub # Add to work GitHub accountCreate or edit ~/.ssh/config:
open -e ~/.ssh/configAdd these host configurations:
# Personal GitHub Account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/github-personal
# Work GitHub Account
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/github-work
Set default account globally:
git config --global user.name "your_personal_username"
git config --global user.email "[email protected]"Clone new repositories:
git clone [email protected]:owner/repo.git # For personal
git clone [email protected]:owner/repo.git # For workUpdate existing repositories:
git remote rm origin
git remote add origin [email protected]:owner/repo.git
git remote set-url origin [email protected]:owner/repo.gitSet repository-specific user:
Default git info set to personal, so for work projects manually change git user.name and user.email
git config user.email "[email protected]"
git config user.name "Your Name"ssh-add -l # Check if keys are loadedIf keys missing, add them again:
ssh-add --apple-use-keychain ~/.ssh/github-personal
ssh-add --apple-use-keychain ~/.ssh/github-work