Skip to content

Instantly share code, notes, and snippets.

@RichVRed
Created February 16, 2017 21:29
Show Gist options
  • Save RichVRed/2dabb06b0e1e9c42653a9dba4d1b3118 to your computer and use it in GitHub Desktop.
Save RichVRed/2dabb06b0e1e9c42653a9dba4d1b3118 to your computer and use it in GitHub Desktop.
put in ${HOME}/bin/git_fix and `chmod +x` it after you install
#!/bin/sh
USAGE="Command Usage:\n\ngit_fix 'email, name' 'old value' 'new value'\n";
if [ "$#" -ne 3 ]; then
echo ${USAGE}
else
case "$1" in
'email')
echo "Changing email from: '$2' to '$3'"
git filter-branch --env-filter "
if [ \"\$GIT_COMMITTER_EMAIL\" = \"$2\" ]
then
export GIT_COMMITTER_EMAIL=\"$3\"
fi
if [ \"\$GIT_AUTHOR_EMAIL\" = \"$2\" ]
then
export GIT_AUTHOR_EMAIL=\"$3\"
fi
" --force --tag-name-filter cat -- --branches --tags
;;
'name')
echo "Changing name from: '$2' to '$3'"
git filter-branch --env-filter "
if [ \"\$GIT_COMMITTER_NAME\" = \"$2\" ]
then
export GIT_COMMITTER_NAME=\"$3\"
fi
if [ \"\$GIT_AUTHOR_NAME\" = \"$2\" ]
then
export GIT_AUTHOR_NAME=\"$3\"
fi
" --force --tag-name-filter cat -- --branches --tags
;;
*)
echo ${USAGE}
;;
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment