Skip to content

Instantly share code, notes, and snippets.

@nodakai
Created September 4, 2024 03:54
Show Gist options
  • Select an option

  • Save nodakai/5b23074c9dbc3143f299498981a3462e to your computer and use it in GitHub Desktop.

Select an option

Save nodakai/5b23074c9dbc3143f299498981a3462e to your computer and use it in GitHub Desktop.

Revisions

  1. nodakai created this gist Sep 4, 2024.
    19 changes: 19 additions & 0 deletions git-reauthor.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/bin/bash

    set -xeu

    git filter-branch --env-filter '
    OLD_EMAIL="nodakai@old.example.net"
    CORRECT_NAME="NODA Kai"
    CORRECT_EMAIL="nodakai@new.example.net"
    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
    ' "$@"