Skip to content

Instantly share code, notes, and snippets.

@seldoff
Created September 26, 2021 16:50
Show Gist options
  • Save seldoff/7039ac89aa92a4ce6cc5eae3ad57f98a to your computer and use it in GitHub Desktop.
Save seldoff/7039ac89aa92a4ce6cc5eae3ad57f98a to your computer and use it in GitHub Desktop.
git with multiple ssh keys on windows
  • Generate two keys
  • Create ~/.ssh/config
  • Put following in it:
Host github.com-user1
	HostName github.com
	User git
	IdentityFile ~/.ssh/[key file for user1]
  
Host github.com-user2
	HostName github.com
	User git
	IdentityFile ~/.ssh/[key file for user2]
  • Change git config for repos accordingly:
[remote "origin"]
	url = [email protected]:[repo for user1]
	fetch = +refs/heads/*:refs/remotes/origin/* 

And same for repos for user2

See https://gist.github.com/jexchan/2351996

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