GIT: Change commiter (author) name

Sometime when I access my GIT repo from the outside form a new station I forget to setup the .gitconfig file >:-(

This script shows how to change the commiter/author:

#!/bin/sh
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "old_name" ];
then
    GIT_COMMITTER_NAME="new_name";
    GIT_AUTHOR_NAME="new_name";
    GIT_COMMITTER_EMAIL="new_email";
    GIT_AUTHOR_EMAIL="new_email";
    git commit-tree "$@";
else
    git commit-tree "$@";
fi' HEAD

Use -f option if it’s not the first change and backup already exists.

Leave a Reply

Your email address will not be published. Required fields are marked *