Skip to content

Instantly share code, notes, and snippets.

@sridhar02
Created November 11, 2021 09:18
Show Gist options
  • Save sridhar02/e34b20007435412b3c9392d052ff0dee to your computer and use it in GitHub Desktop.
Save sridhar02/e34b20007435412b3c9392d052ff0dee to your computer and use it in GitHub Desktop.
Replace git commit history using a shell script
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
@sridhar02
Copy link
Author

commit to version control using this git command

git push --force --tags origin 'refs/heads/*'

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