david alfonso

E-mail privacy in GitHub

Future commits

  1. Check both Keep e-mail private and Block command-line pushes options in your GitHub e-mail settings.
  2. Set your GitHub private e-mail address globally of per-project:
# current project
$ git config user.email "username@users.noreply.github.com"

# global
$ git config --global user.email "username@users.noreply.github.com"

Past commits

WARNING: These steps rewrite your repository history. Read about collaboration and rewriting history.

Last commit

$ git commit --amend --reset-author

Bulk edition

  1. Install git-filter-repo which is the official git filter-branch replacement.

  2. Clone repo (bare or not)

$ git clone --bare https://hostname/user/repo.git
$ cd repo.git
  1. Update e-mail and/or name from all commits matching your old@email.com note the usage of bytes)
# update e-mail only
$ git-filter-repo --email-callback 'return email if email != b"old@email.com" else b"username@users.noreply.github.com"'

# update both e-mail and name
$ git-filter-repo --name-callback 'return b"Your Name"' --email-callback ...
  1. Re-add remote repository (git-filter-repo deletes remotes as a safety measure to avoid unintended history rewrites!)
$ git remote add origin <remote-url>
  1. Force push changes (!)
$ git push origin -f --all

References