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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s