Skip to content

Instantly share code, notes, and snippets.

@mtbiker-s
Created August 15, 2017 00:34
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 mtbiker-s/b309cf51cdd06ce86241e81f95f2e4bd to your computer and use it in GitHub Desktop.
Save mtbiker-s/b309cf51cdd06ce86241e81f95f2e4bd to your computer and use it in GitHub Desktop.
BASH Script to change your git profile from your work profile to your personal GH profile or vice versa.
#!/bin/bash
# That is for OSX
# For *nix use #!/usr/bin/bash
echo "Switching git user profile"
echo
echo "Curent git profile"
git config -l
echo "Please enter which profile to use 'work' or 'personal'"
read profileToUse
if [[ $profileToUse == "work" ]]; then
echo "Setting git profile to access github.work.com"
# Don't forget to change these 2 lines
git config --global user.email "your_address@work.com"
git config --global user.name "your_work_github_username"
else
echo "Setting git profile to access github.com"
# Don't forget to change these 2 lines
git config --global user.email "your_address@personal.email.com"
git config --global user.name "your_git_hub_username"
fi
echo "git profile has been switched to use the profile - "$profileToUse"."
git config -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment