I set up two SSH keys corresponding to two separate GitHub accounts and the ergonomics of my set up aren't quite working for me.
Somewhere (I can't remember where), I have it set up such that if I'm in the dev
folder, it commits with my zackshapiro account and if I'm in my other-dev
folder, it commits with my alt_account.
Here's my ~.ssh/config
:
Host zackshapiro
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes
Host alt_account
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
Host *
AddKeysToAgent yes
UseKeychain yes
And my .zshrc
:
alias ssh-personal="ssh-add -D; ssh-add -K ~/.ssh/id_rsa"
alias ssh-alt="ssh-add -D; ssh-add -K ~/.ssh/id_ed25519"
What's become annoying though are problems with git clone
, and git push
primarily, where I get errors such as these:
When I git push
, I'll get
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
And I have to do git push git@github.com:{account}/{project}
to get the code to push up.
Similarly with git clone
, I can't just do git clone {and paste the link directly from GH}
.
I have to do git clone git@github.com:/{account}/{project}
I'd really like to fix the ergonomics of this so I don't have to search my history, change the text of a previous push or clone and can generally move faster.
Any help would be greatly appreciated!