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

Posted by Steve Purcell at Thu Jun 5 04:49:23 2008

Hi Michael; that's a really neat trick.

Note also that if you're converting darcs to git with my 'darcs-to-git' utility (http://www.sanityinc.com/articles/converting-darcs-repositories-to-git), a recent patch from Thomas Schiller means that you can now supply a mapping file to translate user names/emails during the conversion process.

Add a comment

Name: 
Your email address: 
Your website: 
 
Comment: