Skip to content

Instantly share code, notes, and snippets.

@yashap
Last active July 21, 2024 23:46
Show Gist options
  • Save yashap/7f7ad15c31d5f70975fe3fda9dce4cfa to your computer and use it in GitHub Desktop.
Save yashap/7f7ad15c31d5f70975fe3fda9dce4cfa to your computer and use it in GitHub Desktop.
My Setup for multiple git users on one machine

Mutliple git users on one machine

Because git relies on SSH to really tell who you are, it's a bit tricky to have multiple users on one machine, but the below does the trick (for git 2.3+):

git config --local user.name '<username>'
git config --local user.email '<email>'
git config --local core.sshCommand "ssh -i ~/.ssh/<private_key> -F /dev/null"
git remote set-url origin [email protected]:<username>/<repo>.git

And if it's still using the wrong user, clear the identies my OpenSSH agent knows about:

ssh-add -D

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment