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: