Skip to content

Instantly share code, notes, and snippets.

@bosmievoll
Created October 5, 2012 09:13
Show Gist options
  • Save bosmievoll/3838870 to your computer and use it in GitHub Desktop.
Save bosmievoll/3838870 to your computer and use it in GitHub Desktop.
Script that updates git author/committer
#!/bin/bash
export authors_file=./author_conv_file.txt
if [ ! -f "$authors_file" ]; then
echo "Bad file: $authors_file"
exit 1
fi
git filter-branch -f --env-filter '
get_name () {
grep "^$1=" "$authors_file" |
sed "s/^.*=\(.*\) <.*>$/\1/"
}
get_email () {
grep "^$1=" "$authors_file" |
sed "s/^.*=.* <\(.*\)>$/\1/"
}
GIT_AUTHOR_NAME=$(get_name $GIT_COMMITTER_NAME) &&
GIT_AUTHOR_EMAIL=$(get_email $GIT_COMMITTER_NAME) &&
GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME &&
GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL &&
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
' -- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment