1

I have a public repository on Github in which I still have the initial local commits that were made with my personal e-mail address. There are also some commits with several people, where my personal e-mail address is in the commit message as co-author.

Is there any way to replace my e-mail in all commits and commit messages without creating a new repository and/or losing the issue/PR links to the commits?

This is a shared repository, and we all (the maintainers) are ok with doing this.

gu3adq
  • 11
  • 2
  • 1
    How complex is the repo after the initial commits? You'll likely need to rebase onto a completely new root. – evolutionxbox Jun 13 '23 at 12:46
  • Are you trying to *remove* your personal e-mail address from the repository, or are you just concerned about people being able to reach you at the correct address? I would argue that contact information should be taken from a README file or the like, not arbitrary commits. – chepner Jun 13 '23 at 12:51
  • You could use a [mailmap](https://git-scm.com/docs/gitmailmap). – Benjamin W. Jun 13 '23 at 12:58
  • 1
    @evolutionxbox unfortunately the repo has a couple of hundreds commits already... – gu3adq Jun 13 '23 at 16:55
  • 1
    @chepner I mean, this is the reason I want to remove the e-mail address, but I know it seems a little paranoid :D I just want to keep my inbox spam-free – gu3adq Jun 13 '23 at 16:56
  • @BenjaminW. Could you please show me how can I use mailmap to change all commits in the past? – gu3adq Jun 13 '23 at 16:57
  • The mailmap wouldn't change commits, but clean up the output of all the commands such as `git log`, `git shortlog`, `git blame` etc. by fetching the canoncail name/email pair from the `.mailmap` file. – Benjamin W. Jun 13 '23 at 17:32
  • I see from your comments that you actually want to edit the actual commits, so a mailmap won't help you there. – Benjamin W. Jun 13 '23 at 17:33
  • Possible duplicate: [Git, rewrite previous commit usernames and emails](https://stackoverflow.com/questions/2919878/git-rewrite-previous-commit-usernames-and-emails). A number of answers are depending on `git filter-branch`. Proceed with caution, especially since it's a shared repository. – ojchase Jun 13 '23 at 18:31
  • @BenjaminW. Yes, thanks! – gu3adq Jun 14 '23 at 09:56
  • @ojchase Thank you! I'll look into it. Can I make somehow backup the repository before I push, in case something goes wrong? – gu3adq Jun 14 '23 at 09:57
  • @gu3adq Probably. On some level just a copy/paste of the full directory structure (especially the .git directory) is a backup, but I see some better solutions over [here](https://stackoverflow.com/questions/5578270/fully-backup-a-git-repo). – ojchase Jun 14 '23 at 19:29

0 Answers0