Change committer in Git commit history

At SteelHouse, we have a unique culture. And one of our more interesting perks is that you get to keep your company laptop.

Except for extreme cases, if you part ways with SteelHouse, that laptop is yours. And we aren't offloading some hand-me-down, early model Dell; These are fresh-from-the-Apple-Store MacBook Pros.

Because of this, sometimes my personal work gets mixed in with my professional work. Sometimes I'm 50 commits deep in GitHub before I realize I've been committing with my work email address for git global user.email.

Whoops.

The following git command can pull you out of this jam, instead of fixing each commit in git log.

git filter-branch --env-filter '  
oldemail="wes@steelhouse.com"  
newemail="wes@futureprefect.com"  
[ "$GIT_AUTHOR_EMAIL"="$oldemail" ] && GIT_AUTHOR_EMAIL="$newemail"
[ "$GIT_COMMITTER_EMAIL"="$oldemail" ] && GIT_COMMITTER_EMAIL="$newemail"
' HEAD  

wgj

Read more posts by this author.