Skip to content

Instantly share code, notes, and snippets.

@ritiek
Last active August 22, 2023 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritiek/b92abd2c26ec30bff14b43ce673fb6c2 to your computer and use it in GitHub Desktop.
Save ritiek/b92abd2c26ec30bff14b43ce673fb6c2 to your computer and use it in GitHub Desktop.
Change git identity for current repository
# Generate SSH keys for Bob and add them to ssh-agent
# Write it to `~/.ssh/bob.id_rsa`.
ssh-keygen -t ed25519
ssh-add ~/.ssh/bob.id_rsa
git config --local user.name Bob
git config --local user.email "bobisthebest@example.com"
git config --local credential.username bobxyz
git config --replace-all --local core.sshCommand "ssh -i ~/.ssh/bob.id_rsa"
# Bonus: signing commits using bob's SSH key generated above
git config --local gpg.format ssh
git config --local commit.gpgSign true
git config --local tag.gpgSign true
echo "bobisthebest@example.com $(cat ~/.ssh/bob.id_rsa.pub)" > ~/.ssh/bob.allowed_signers
git config --local gpg.ssh.allowedSignersFile ~/.ssh/bob.allowed_signers
git config --local --replace-all user.signingKey "key::$(cat ~/.ssh/bob.id_rsa.pub)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment