Today I needed to rewrite some git repo commits from a very recently created repository where only I had committed, but from multiple systems with different setups; my usual setup with the proper info, another one where I didn't add the global user.email git property yet, and also added the license file from gitlab itself. So basically I had three different mail addresses and two different names associated with different commits that I wanted to unify, as that's a pretty messed up history for a very recent repo.
As I found on this question on StackOverflow about git author rewriting, that can be done with git-filter-repo tool:
For installing it, I used brew (but it's available in most package managers) with just:
brew install git-filter-repo
So then you can use it as:
git-filter-repo --name-callback 'return name.replace(b"oldName", bytes("newNameWithUtf8Chars", "utf-8"))' --email-callback 'return email.replace(b"email@example.com", b"firstname.lastname@example.org")' --force
After that I had to re-add the remote and git push --force. Take into account that this rewrites history, so you (and your team) might need to reclone the repo. Please plan this accordingly.
Also take into account that if the branch is protected, you might need to add permissions for allowing to push. I allowed that temporarily following Allow force push on a protected branch on Gitlab docs.