-
-
Save burakbozyigit/7706bf2d31cce64c09eb03275894f210 to your computer and use it in GitHub Desktop.
A Bash script to interchange multiple GitHub users in a unique machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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