git filter-branch -f --env-filter '
WRONG_EMAIL="<wrong_email>"
NEW_NAME="<username>"
NEW_EMAIL="<your_email>"
if [ "$GIT_COMMITTER_NAME" = "De Backer Christophe" ]
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
Then you need to use
git push -f <remote> <branch>
-
git
log to find the commit you want to remove and copy its hash -
git rebase -i <commit_hash>~
which opens your text editor -
In text editor, switch from
pick
todrop
for your particular commit -
Then you may want to use an
git rebase --continue