Fixing git author data in retrospect

Usually if one gets started with git not everything is set up correctly and thus the repository data may be malformed, i.e. the author name or email isn’t correct. Changing this data in retrospect is possbile as the following short bash script shows:

#!/bin/sh

git filter-branch --env-filter '

an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_NAME" = "pascal_old" ]
then
   cn="pasal_new"
   cm="pascal@foobar.de"
fi
if [ "$GIT_AUTHOR_NAME" = "pascal_old" ]
then
   am="pascal@foobar.de"
   an="pascal_new"
fi

export GIT_AUTHOR_EMAIL=$am
export GIT_COMMITTER_EMAIL=$cm
export GIT_AUTHOR_NAME=$an
export GIT_COMMITTER_NAME=$cn

'
Advertisements