-
-
Save jvahldick/e7b56e6e55e475b4b4d0bd9c45233dab to your computer and use it in GitHub Desktop.
Place the script on /usr/local/bin/git to change the name and email before executing the git command
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
#!/usr/bin/env bash | |
GIT_SCRIPT=$(which -a git | sed -n 2p) | |
# Does the remote "origin" point to GitHub? | |
if ("$GIT_SCRIPT" remote -v 2>/dev/null | | |
grep '^origin\b.*github.com.*(push)$' >/dev/null 2>&1); then | |
# Yes. Set username and email that you use on GitHub. | |
export GIT_AUTHOR_NAME='*** username ***' | |
export GIT_AUTHOR_EMAIL='*** email ***' | |
fi | |
# Does the remote "origin" point to BitBucket? | |
if ("$GIT_SCRIPT" remote -v 2>/dev/null | | |
grep '^origin\b.*bitbucket.org.*(push)$' >/dev/null 2>&1); then | |
# Yes. Set username and email that you use on Bitbucket. | |
export GIT_AUTHOR_NAME='*** username ***' | |
export GIT_AUTHOR_EMAIL='*** email ***' | |
fi | |
"$GIT_SCRIPT" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment