Created
March 25, 2020 08:54
-
-
Save hantuzun/a3fa1653bb8078e788f241f540fabaf6 to your computer and use it in GitHub Desktop.
Set Git author config and optionally update commit author
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/sh | |
# Set git author | |
export NAME = "Han Tuzun" | |
export EMAIL = "mail@hantuzun.com" | |
export GITHUB_USER = "hantuzun" | |
git config --global user.name $NAME | |
git config --global user.email $EMAIL | |
git config --global github.user $GITHUB_USER | |
# Optional: Update previous commits | |
export OLD_NAME = "" | |
export OLD_EMAIL = "" | |
git config alias.change-commits '!'"f() { VAR=\$1; OLD=\$2; NEW=\$3; shift 3; git filter-branch -f --env-filter \"if [[ \\\"\$\`echo \$VAR\`\\\" = '\$OLD' ]]; then export \$VAR='\$NEW'; fi\" \$@; }; f " | |
git change-commits GIT_AUTHOR_NAME $OLD_NAME $NAME | |
git change-commits GIT_AUTHOR_EMAIL $OLD_EMAIL $EMAIL | |
git change-commits GIT_COMMITTER_EMAIL $OLD_EMAIL $EMAIL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment