Skip to content

Instantly share code, notes, and snippets.

@erkobridee
Last active June 18, 2025 13:14
Show Gist options
  • Save erkobridee/ce99e1178522de4fdf0293874f07fb0c to your computer and use it in GitHub Desktop.
Save erkobridee/ce99e1178522de4fdf0293874f07fb0c to your computer and use it in GitHub Desktop.

Using multiple git accounts on the same machine

GIT_SSH_COMMAND='ssh -i PATH/TO/KEY/FILE -o IdentitiesOnly=yes' git clone [email protected]:OWNER/REPOSITORY

or add the following config on the .gitconfig

[core]
    sshCommand = ssh -i PATH/TO/KEY/FILE -o IdentitiesOnly=yes -F /dev/null

Example

  • .gitconfig
[includeIf "gitdir:~/dev_work/"]
    path = ~/.gitconfig_work

[includeIf "gitdir:~/dev_personal/"]
    path = ~/.gitconfig_personal
  • .gitconfig_work
[credential]
	helper = !aws codecommit credential-helper $@
	UseHttpPath = true
[user]
	name = Your Name
	email = [email protected]
  • .gitconfig_personal
[user]
	name = Your Name
	email = [email protected]
	signingKey = ~/.ssh/github/id_ed25519_personal.pub

[core]
    sshCommand = ssh -i ~/.ssh/github/id_ed25519_personal -o IdentitiesOnly=yes -F /dev/null

[gpg]
	format = ssh

[commit]
	gpgsign = true

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