Skip to content
Snippets Groups Projects

Changing author names across history

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Chris Woodall
    snippetfile1.txt 607 B
    #!/bin/sh
    
    git filter-branch --env-filter '
    OLD_EMAIL="email-address@barrett.com"
    CORRECT_NAME="New Name"
    CORRECT_EMAIL="new-email@barrett.com"
    if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
    then
        export GIT_COMMITTER_NAME="$CORRECT_NAME"
        export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
    fi
    if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
    then
        export GIT_AUTHOR_NAME="$CORRECT_NAME"
        export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
    fi
    ' --tag-name-filter cat -- --branches --tags
    
    # Once this is done you will need to do the following (and remove protected branches
    # git push --force --tags origin 'refs/heads/*'
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment