Created
October 16, 2012 00:55
-
-
Save alexander-bauer/3896675 to your computer and use it in GitHub Desktop.
git authorship and email adjustment
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 | |
# This script uses git filter-branch to adjust author names and | |
# emails. No success is garuenteed. Usage is as follows: | |
# | |
# gitfix.sh --name|--email oldValue newValue | |
# | |
OLDVALUE=$2 | |
NEWVALUE=$3 | |
if [ "$1" != "--name" ] && [ "$1" != "--email" ] | |
then | |
echo "usage: $0 option oldValue newValue | |
options: | |
--name adjust GIT_AUTHOR_NAME and GIT_COMMITTER_NAME | |
--email adjust GIT_AUTHOR_EMAIL and GIT_COMMITTER_EMAIL" | |
fi | |
if [ "$1" = "--name" ] | |
then | |
git filter-branch -f --env-filter " | |
if [ \"\$GIT_AUTHOR_NAME\" = \"$OLDVALUE\" ] | |
then | |
export GIT_AUTHOR_NAME=\"$NEWVALUE\" | |
fi | |
if [ \"\$GIT_COMMITTER_NAME\" = \"$OLDVALUE\" ] | |
then | |
export GIT_COMMITTER_NAME=\"$NEWVALUE\" | |
fi | |
" HEAD | |
elif [ "$1" = "--email" ] | |
then | |
git filter-branch --env-filter " | |
if [ \"\$GIT_AUTHOR_EMAIL\" = \"$OLDVALUE\" ] | |
then | |
export GIT_AUTHOR_EMAIL=\"$NEWVALUE\" | |
fi | |
if [ \"\$GIT_COMMITTER_EMAIL\" = \"$OLDVALUE\" ] | |
then | |
export GIT_COMMITTER_EMAIL=\"$NEWVALUE\" | |
fi | |
" HEAD | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment