Skip to content

Instantly share code, notes, and snippets.

@burakbozyigit
Forked from cr0wg4n/switch-github-user.sh
Created December 16, 2024 12:33
Show Gist options
  • Save burakbozyigit/7706bf2d31cce64c09eb03275894f210 to your computer and use it in GitHub Desktop.
Save burakbozyigit/7706bf2d31cce64c09eb03275894f210 to your computer and use it in GitHub Desktop.
A Bash script to interchange multiple GitHub users in a unique machine
#!/bin/bash
gh_user="${1:-Nothing}"
if [ "$gh_user" == 'USERNAME_1' ]; then
ssh-add -D
git config --global user.email "USERNAME_1_EMAIL"
ssh-add /PRIVATE_KEY_PATH/.ssh/github-USERNAME_1
elif [ "$gh_user" == 'USERNAME_2' ]; then
ssh-add -D
git config --global user.email "USERNAME_2_EMAIL"
ssh-add /PRIVATE_KEY_PATH/.ssh/github-USERNAME_2
else
echo 'Nothing was applied'
exit 1
fi
echo "$gh_user applied!"
git config user.email
ssh -T [email protected]
exit 0
# TO USE
# ./switch-github-user.sh USERNAME_1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment