Skip to content

Instantly share code, notes, and snippets.

@smpb
Created December 17, 2012 15:15
Show Gist options
  • Save smpb/4319026 to your computer and use it in GitHub Desktop.
Save smpb/4319026 to your computer and use it in GitHub Desktop.
When juggling the setup of several git repositories it's easy to forget to configure the adequate e-mail address you want associated with your commits. Personally, I am guilty of regularly adding the address of my personal projects onto work commits, and vice-versa. Be aware that you are rewriting git history by using this.
#!/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_EMAIL" = "the_dude@ibowl.com" ]
then
cn="The Dude"
cm="el_duderino@ibowl.com"
fi
if [ "$GIT_AUTHOR_EMAIL" = "the_dude@ibowl.com" ]
then
an="The Dude"
am="el_duderino@ibowl.com"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'
@smpb
Copy link
Author

smpb commented Dec 17, 2012

This is a personal copy of the solution I found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment