Subject:

make git username/emails mutable


Message-Id: https://www.5snb.club/w/make-git-username-emails-mutable/
Linked-From: wiki.

this is very much an experiment and maybe not a good idea

but it seems to work

the core premise is “you set your name to a UUID then use a mailmap file to map that back to something readable”

  1. Generate some UUID. Then use

    • git config --local --add user.name "f0454d23-417c-446b-802d-8b56153fbdf8"
    • git config --local --add user.email "f0454d23-417c-446b-802d-8b56153fbdf8"
  2. git checkout --orphan mailmap
    This makes a branch that isn’t attached to anything else (since you’re not putting any code on it).

  3. make your mailmap file (you can call it whatever, but just calling it mailmap in the root of the directory works fine), and commit it.

    For reference, the syntax is

    5225225 <5225225@mailbox.org> <f0454d23-417c-446b-802d-8b56153fbdf8>
    
  4. git config --local mailmap.blob mailmap:mailmap
    this tells git to look in the mailmap branch for the file named mailmap

    Notably, this branch doesn’t have any code on it, so you can freely rebase to squash it any time you want. (But you don’t have to do that on every commit).

If you’re running a server, you might also want to block pushes that contain a “real” username/email, since it would be easy to accidentally get a non-uuid username into the history, and then you’d need to rebase to remove it, which is the whole thing this is trying to avoid

also, anyone viewing wouldn’t see correct emails unless they did step 4.