Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Written to change the unix name used for a cvs commit to a pretty git name for the user.Implementation borrowed from format (same format as git-cvsimport requires):
# Changes author and committer name and email throughout the whole repository.
# Uses a file with the following format:
# Doe <>
# Doe <>
if [ ! -e "$1" ]
echo "File '$1' does not exist"
exit 1
export authors_file=$1
git filter-branch -f --env-filter '
grep "^$GIT_COMMITTER_EMAIL=" "$authors_file" >> /dev/null
if [ $RETVAL -eq 0 ]
get_name () {
grep "^$1=" "$authors_file" |
sed "s/^.*=\(.*\) <.*>$/\1/"
get_email () {
grep "^$1=" "$authors_file" |
sed "s/^.*=.* <\(.*\)>$/\1/"
name=$(get_name "$GIT_COMMITTER_EMAIL")
email=$(get_email "$GIT_COMMITTER_EMAIL")
GIT_AUTHOR_NAME="$name" &&
GIT_AUTHOR_EMAIL="$email" &&
' -- --all

stigkj commented Dec 9, 2011

Improved implementation by

  • taking the auth-conv-file to use as an argument
  • use email as key instead of name to get around the problem with foreign letters
  • more quoting

Can this be adopted to include a list of Git contributors emails -- not a cvs import -- and then go through the list? Change the user and email based only on the old email.


stigkj commented Apr 17, 2012

You mean you do not have a file, just a list inline in the script?

Having a file, but only base the cycle on emails, and end up with one author(name+email).


stigkj commented Apr 18, 2012

Not sure I is based on emails, that is, commits with emails matching the first column in the file will get their name and email replaced from the second column of the file

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