You use a personal and a work GitHub account on one laptop.
IntermediateScenarioRemotes, Collaboration and Pull Requests
Answer
Situation read → SSH picks the first matching key, which authenticates as the wrong user.
What I'd do →
- Create two keys and add each to its own account.
- In
~/.ssh/config:
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
IdentitiesOnly yes
- Clone with
git@github-work:ORG/repo.git. - Set the email per directory with
includeIf "gitdir:~/work/"in~/.gitconfig.
Why → The alias selects the key, and IdentitiesOnly stops the agent from offering others.
Interview tip → includeIf avoids committing work code with your personal email.
More on Remotes, Collaboration and Pull Requests
You are new to a team. How do you collaborate daily without stepping on others' toes?BeginnerYou are migrating a repo from Bitbucket to GitHub and must keep every branch and tag.IntermediateYou want to contribute a fix to an open-source project you do not have write access to.BeginnerA teammate sent a 3,000-line PR and nobody can review it properly.IntermediateA reviewer asks for changes. How do you update the PR cleanly?BeginnerYour team wants stacked PRs so that large work arrives in small reviewable steps. How do you set it up?Advanced