Samuel Plumppu

Update Your Git Commit Email Address Before Pushing to Remote Repository

GitCode Snippet

Here's a quick way to update commit author email and display name for previous commits in a local project.

Two things worth mentioning before using this:

  1. If you change your email, it might no longer count as contributions on your GitHub/GitLab profile. But as long as you keep the old email as a hidden email connected to your account, it should work.

  2. Remember that rewriting history in shared projects is a bad idea. Especially when working in a collaborative environment with other people. But for old local projects that you want to upload to a public Git repository, this method could be useful to hide some personal information.

Let's use git-filter-repo which is a modern replacement to git filter-branch and can be installed via package managers or by following the official install guide.

Once installed, we can update the email like this:

If you also want to update your name, you can run this command:

Credit: StackOverflow

Thank you for reading! 🌱

Read 9 more posts or learn more about me.