Skip to content

Instantly share code, notes, and snippets.

@kevinpiac
Created March 26, 2017 08:53
Show Gist options
  • Save kevinpiac/9ea6a9ddb0b5835055e22c11189563c2 to your computer and use it in GitHub Desktop.
Save kevinpiac/9ea6a9ddb0b5835055e22c11189563c2 to your computer and use it in GitHub Desktop.
Edit commit author's Name / Email on Github
#!/bin/sh
REPO_NAME="your_repo_name"
git clone --bare "git@github.com:<username>/$REPO_NAME"
cd "$REPO_NAME"
git filter-branch --env-filter '
OLD_NAME="Name You want to change"
CORRECT_NAME="Name you want to replace by"
CORRECT_EMAIL="Email you want to replace by"
if [ "$GIT_COMMITTER_NAME" = "$OLD_NAME" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_NAME" = "$OLD_NAME" ] #
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
git push --force --tags origin 'refs/heads/*'
cd ..
rm -rf "$REPO_NAME"
@kevinpiac
Copy link
Author

kevinpiac commented Mar 26, 2017

This example shows how to edit your author info based on "COMMITTER_NAME" and "AUTHOR_NAME".
You can also use "COMMITTER_EMAIL" and "AUTHOR_EMAIL" if needed.

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