Last active
October 23, 2024 23:58
-
-
Save cr0wg4n/39e691d5f2140bce641448b0f56e6a9e to your computer and use it in GitHub Desktop.
A Bash script to interchange multiple GitHub users in a unique machine
This file contains 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
Works great!