Replacing Author for Multiple Git Commits

Some time ago I was taking the course Master Microservices with Spring Boot and Spring Cloud but I had to leave it because these days I was getting very busy. Yesterday, after three months, I returned back and after pushing changes to GitLab repo, I noticed that changes were made with my GitHub email address instead of using the GitLab one.

Last commit could be easily changed with the command below:

$ git commit --amend --author="Joseba Martos <1229008-josebamartos@users.noreply.gitlab.com>"
$ git push --force

But I detected other changes committed before with the wrong email address, so I used this script I developed for this kind of situations:

Just set the mail address of the committer to replace into variable OLD_EMAIL, new committer’s name in CORRECT_NAME and new committer’s email in CORRECT_EMAIL. Give execution permissions and run, it will replace the committer and tell you which the next steps are.

$ chmod +x
$ ./git-chauthor.sh

I hope this information will help you out of trouble when your commits have incorrect information. Remember to always keep your identity clear, buccaneer. Good winds!