Open Source + Work
This guide covers managing separate GitHub accounts for open source work and day job.
The scenario
Section titled “The scenario”You want:
- Work account — for company repos, closed-source projects
- OSS account — for personal GitHub projects, public contributions, open source
Different SSH keys, different GitHub accounts, different emails.
1. Generate SSH keys
Section titled “1. Generate SSH keys”# Work SSH keyssh-keygen -t ed25519 -f ~/.ssh/id_work -C "alice@company.com"
# OSS SSH keyssh-keygen -t ed25519 -f ~/.ssh/id_oss -C "alice@github.com"2. Add to GitHub accounts
Section titled “2. Add to GitHub accounts”Work GitHub account:
- Go to https://github.com/settings/keys
- Add
~/.ssh/id_work.pub - Test:
ssh -T git@github.com(should auth as work account)
OSS GitHub account:
- Log into your personal GitHub account
- Go to https://github.com/settings/keys
- Add
~/.ssh/id_oss.pub - Test:
ssh -T git@github.com(should auth as OSS account)
3. Create gitswitch profiles
Section titled “3. Create gitswitch profiles”# Work profilegitswitch add work "Alice Smith" alice@company.com \ --ssh-key ~/.ssh/id_work \ --gh-user alice-work
# OSS profilegitswitch add oss "Alice" alice@github.com \ --ssh-key ~/.ssh/id_oss \ --gh-user alice-ossDaily workflow
Section titled “Daily workflow”Before starting work
Section titled “Before starting work”# Working on company projectcd ~/work/internal-apigitswitch work# Now commits show alice@company.com, using id_work SSH key
# Working on open sourcecd ~/projects/my-librarygitswitch oss# Now commits show alice@github.com, using id_oss SSH keyWith automatic nudges
Section titled “With automatic nudges”If you’ve run gitswitch install:
cd ~/work/internal-api# gitswitch: this repo usually uses work — switch? [y/N]
cd ~/projects/my-library# gitswitch: this repo usually uses oss — switch? [y/N]Pin the repos for permanent association:
cd ~/work/internal-apigitswitch pin work
cd ~/projects/my-librarygitswitch pin ossTypical workflow: Contributing to OSS
Section titled “Typical workflow: Contributing to OSS”1. Fork a project
Section titled “1. Fork a project”# Fork on GitHub UI as your OSS account# Clone your forkgit clone git@github.com:alice-oss/external-project.gitcd external-project2. Switch identity
Section titled “2. Switch identity”gitswitch oss# Verifygitswitch current# → oss / alice@github.com3. Create feature branch and commit
Section titled “3. Create feature branch and commit”git checkout -b add-cool-featuregit add .git commit -m "Add cool feature"# Commit attributed to alice@github.com4. Push and create PR
Section titled “4. Push and create PR”git push origin add-cool-feature# Push from correct account (using id_oss)Go to GitHub and create PR. Your OSS account shows as contributor.
Typical workflow: Company development
Section titled “Typical workflow: Company development”1. Clone internal repo
Section titled “1. Clone internal repo”git clone git@github.com:company/internal-api.gitcd internal-api2. Switch identity
Section titled “2. Switch identity”gitswitch work# Verifygitswitch current# → work / alice@company.com3. Develop and commit
Section titled “3. Develop and commit”git checkout -b fix/critical-buggit add .git commit -m "Fix critical bug"# Commit attributed to alice@company.com4. Push and create PR
Section titled “4. Push and create PR”git push origin fix/critical-bug# Push from correct account (using id_work)Create PR on company GitHub. Your work account shows as contributor.
Using gh CLI with both accounts
Section titled “Using gh CLI with both accounts”If you use gh (GitHub CLI), it respects the GitHub account switch:
# As OSS accountgitswitch ossgh repo list# Lists your personal repos
gh pr create --title "My feature" --body "..."# Creates PR from OSS account
# Switch to workgitswitch workgh repo list# Lists company repos
gh pr create --title "Fix" --body "..."# Creates PR from work accountCommon scenarios
Section titled “Common scenarios”Contributing to OSS from work computer
Section titled “Contributing to OSS from work computer”# My work laptop has both company and personal reposcd ~/work/internal-projectgitswitch work
# But also:cd ~/work/side-projects/oss-contribgitswitch oss# Switch to OSS identity before contributingReviewing different repos
Section titled “Reviewing different repos”# Check work PRgitswitch workgh pr list --repo company/internal-api
# Check OSS issuesgitswitch ossgh issue list --repo my-project/repoKeeping work and personal GitHub notifications separate
Section titled “Keeping work and personal GitHub notifications separate”With both accounts authenticated and gh support, you can:
gitswitch workgh notification list# Shows work notifications
gitswitch ossgh notification list# Shows OSS notificationsTroubleshooting
Section titled “Troubleshooting”Accidentally committed work code to OSS identity
Section titled “Accidentally committed work code to OSS identity”If you forgot to switch before committing:
# Check current identitygitswitch current# → wrong identity
# Switch to correct onegitswitch work
# Amend the commit to fix authorgit commit --amend --reset-authorSSH key rejected when pushing
Section titled “SSH key rejected when pushing”If SSH fails:
# Verify correct identity is activegitswitch current
# Test SSH directlyssh -T git@github.com# Should show you're authenticated as that account
# Check git's SSH configgit config --global core.sshCommandPushing to wrong account’s repo
Section titled “Pushing to wrong account’s repo”If you pushed to OSS account but meant work account:
# Check current identitygitswitch current
# If wrong, switchgitswitch work
# The commit is already pushed, but future commits use right account# You can ask GitHub to change PR owner or push from correct accountToo many GitHub notifications
Section titled “Too many GitHub notifications”Managing notifications across accounts can be overwhelming:
- Use GitHub’s notification settings
- Label repos by account in local naming
- Create aliases for quick switching
alias gsw='gitswitch work'alias gso='gitswitch oss'
gsw # Quick switch to workgso # Quick switch to OSSAdvanced: Filtering by directory
Section titled “Advanced: Filtering by directory”Automatically switch based on directory:
# Add to ~/.zshrcfunction cd() { builtin cd "$@"
if [[ $PWD == *"/work/"* ]]; then gitswitch work 2>/dev/null elif [[ $PWD == *"/projects/"* ]]; then gitswitch oss 2>/dev/null fi}Now switching directories automatically suggests the right identity.