Problem Statement

I have two different GitHub accounts: my work account and my personal account. I want to be able to contribute to my personal Quartz repository from my work laptop. To do this, I need to setup two separate GitHub accounts within my ssh/git configuration on my work local machine.

The Goal

  • My work laptop uses xxx.githubenterprise.com for your work account.
  • I want to push to a private personal GitHub repo (Quartz) on github.com without interfering with work Git.
  • I want my commits to be under my personal GitHub identity for the Quartz repo.
  • I want to keep the Quartz repo private and editable from both devices.

The Solution

  1. First, generate a new SSH key pair on your work laptop for your personal GitHub.
    ssh-keygen -t ed25519 -C "your_personal_email@example.com"
     # Save as: ~/.ssh/id_ed25519_personal
  2. Then, add this key to your ~/.ssh/config.
    # ~/.ssh/config
     
    # Personal GitHub
    Host github.com-personal
      HostName github.com
      User git
      IdentityFile ~/.ssh/id_ed25519_personal
      IdentitiesOnly yes		
  3. Then add your public key (~/.ssh/id_ed25519_personal.pub) to your personal GitHub account under: > GitHub → Settings → SSH and GPG Keys → New SSH Key
  4. Clone the Quartz Repo Using the Custom Host.
    git clone git@github.com-personal:yourusername/quartz.git ~/quartz
     cd ~/quartz
  5. Configure Git Locally for the Quartz Repo
    git config user.name "Your Name"
     git config user.email "your_personal_email@example.com"
     
     # verification within repo
     git config --get user.email
     git config --get user.name
  6. Set Remote URL to Avoid Mistakes
    git remote set-url origin git@github.com-personal:yourusername/quartz.git

Linked Map of Contexts