E-mail privacy in GitHub
Future commits
- Check both
Keep e-mail privateandBlock command-line pushesoptions in your GitHub e-mail settings. - Set your GitHub private e-mail address globally of per-project:
# current project
$ git config user.email "12345678+username@users.noreply.github.com"
# global
$ git config --global user.email "12345678+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 --no-edit \
--author="$(git config user.name) <$(git config user.email)>"
Bulk edition
-
Install
git-filter-repowhich is the officialgit filter-branchreplacement. -
Clone repo (bare or not)
$ git clone --bare https://hostname/user/repo.git
$ cd repo.git
- Update e-mail and/or name from all commits matching your
old@email.comusing themailmapmechanism:
# This file follows gitmailmap format: https://git-scm.com/docs/gitmailmap
$ cat >/tmp/mailmap <<EOF
<12345678+username@users.noreply.github.com> <old@email.com>
EOF
$ git filter-repo --mailmap /tmp/mailmap
# Alternative: Create .mailmap and then --use-mailmap
- Verify author information has been correctly updated:
$ git log --all --format='%ae%n%ce' | sort -u
- Re-add remote repository (
git-filter-repodeletes remotes as a safety measure to avoid unintended history rewrites!)
$ git remote add origin <remote-url>
- Force push changes (!)
$ git push --force --branches --tags --prune origin