Xavier Rubio Jansana

Xavier Rubio Jansana

Mobile engineer.
Android and iOS.
Scuba diver.

© 2024

Fixing privacy issues in GitHub commits

GitHub has a setting to protect user privacy by not allowing changes to be pushed to GitHub where author email is one of the ones informed in your Settings.

Activities detail

Given that the git configuration in my development machine is used for work too, global configuration uses my work email. Because of that, I have to remember configuring the email alias that GitHub uses instead of my real email… And sometimes I forget to do it. So, when I do a git push I receive an error.

There’s an easy fix for this, by changing the configuration and then amending the commit like so (my email alias in GitHub is xrubioj@users.noreply.github.com):

git config user.email xrubioj@users.noreply.github.com
git commit --amend --author="Xavier Rubio Jansana <xrubioj@users.noreply.github.com>" && git rebase --continue

Improvement on 20.08.2021

From the following answer in StackOverflow, if you need to fix multiple commits, you could do the following:

git config user.email xrubioj@users.noreply.github.com
git rebase -i YOUR_SHA -x "git commit --amend --author 'Xavier Rubio Jansana <xrubioj@users.noreply.github.com>' -CHEAD"

The changes will be applied to all the commits after YOUR_SHA.