Skip to content

Instantly share code, notes, and snippets.

@MrZyr0
Created June 22, 2022 07:48
Show Gist options
  • Save MrZyr0/bdfdf73b5a5290e783d8c344c764c7c8 to your computer and use it in GitHub Desktop.
Save MrZyr0/bdfdf73b5a5290e783d8c344c764c7c8 to your computer and use it in GitHub Desktop.
Use `git filter-branch` to do some processing on all commits of a branch
#!/bin/bash
git filter-branch --env-filter '
WRONG_EMAIL="john@example.com"
NEW_NAME="John Doe"
NEW_EMAIL="doe@exmaple.com"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment