Overwrite all git commit’s author

As a little post-it, here’s a script to amend author’s name and email of all commits of a repository. Use with care, it will override all commits, no matter what the original author is.

#!/bin/sh

if [ "$#" -ne 2 ]; then
	echo "usage: amend 'name' 'email'"
	exit 1
fi

git filter-branch -f --env-filter "
	GIT_AUTHOR_NAME='$1'
	GIT_AUTHOR_EMAIL='$2'
	GIT_COMMITTER_NAME='$1'
	GIT_COMMITTER_EMAIL='$2'
" HEAD

Credit: https://stackoverflow.com/a/750191/913135

Leave a Reply

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