mwolson.org Blog - /Tech

Wed, 04 Jun 2008

Tech tip: Modifying authorship information in git repos

So you've recently converted a darcs repo into a git repo. Good choice! Unfortunately, the conversion process made it so that people who used a short login name rather than a full name when committing now have the email address for their commits set to your own email address. Not good. Here's how to fix that, by changing the email address in their commits to be just their short login name.

git checkout master
git checkout -b rebased
git-filter-branch --env-filter \
  'if test "$GIT_AUTHOR_NAME" = $(echo $GIT_AUTHOR_NAME | cut -f 1 -d" "); \
  then export GIT_AUTHOR_EMAIL=$GIT_AUTHOR_NAME; fi' HEAD

If you like what you see, then it suffices to do the following to make the master branch point to the new commit history.

git checkout master
git reset --hard rebased
git branch -D rebased