Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save coltenkrauter/c71c7741f72eafdbdaec54f29979ac8a to your computer and use it in GitHub Desktop.
Save coltenkrauter/c71c7741f72eafdbdaec54f29979ac8a to your computer and use it in GitHub Desktop.
Update all commits of a branch with new author and committer information.
NEW_AUTHOR_NAME="John Doe"
NEW_AUTHOR_EMAIL="[email protected]" # Private Git Email
# Start filter-branch to rewrite the author information for all commits
git filter-branch -f --env-filter '
CORRECT_NAME="'"$NEW_AUTHOR_NAME"'"
CORRECT_EMAIL="'"$NEW_AUTHOR_EMAIL"'"
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
' --tag-name-filter cat -- --branches --tags
# Force push the rewritten commits (Be cautious with force pushing)
echo "Pushing corrected commits..."
git push --force-with-lease
echo "Author correction complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment