Skip to content

Instantly share code, notes, and snippets.

@maciej
Created June 27, 2013 11:40
Show Gist options
  • Save maciej/5875814 to your computer and use it in GitHub Desktop.
Save maciej/5875814 to your computer and use it in GitHub Desktop.
git: Changes a commit's GIT_COMMITER_NAME|EMAIL to GIT_AUTHOR_NAME|EMAIL
#!/bin/sh
#
# Changes a commit's GIT_COMMITER_NAME|EMAIL to GIT_AUTHOR_NAME|EMAIL
#
# set-commiter-to-author [-f] commit-to-change
#
# If -f is supplied it is passed to "git filter-branch".
#
# If <branch-to-rewrite> is not provided or is empty HEAD will be used.
# Use "--all" or a space separated list (e.g. "master next") to rewrite
# multiple branches.
#
# Based on http://stackoverflow.com/questions/3042437/change-commit-author-at-one-specific-commit
force=''
if test "x$1" = "x-f"; then
force='-f'
shift
fi
br="${1:-HEAD}"
TARG_COMMIT="$targ"
export TARG_COMMIT
filt='
if test "$GIT_AUTHOR_NAME" != "$GIT_COMMITTER_EMAIL"; then
GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
export GIT_COMMITTER_EMAIL
export GIT_COMMITTER_NAME
fi
'
git filter-branch $force --env-filter "$filt" -- $br
@jpuck
Copy link

jpuck commented Apr 10, 2017

is this right?

if test "$GIT_AUTHOR_NAME" != "$GIT_COMMITTER_EMAIL"; then

shouldn't it be:

if test "$GIT_AUTHOR_EMAIL" != "$GIT_COMMITTER_EMAIL"; then

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