On Deadnames and Git

Published 2021-03-09 on Cara's Blog - Permalink

Coming out is a hard thing no matter what form it takes. People who have known you for years or decades now need to reconcile the true you with the you that they’ve known for so long. This is hard enough for sexual orientations, but throw in new pronouns or a new name and the whole experience gets so much harder. There’s inevitably going to be stumbling blocks, either accidental or intentional, and part of coming out is learning to deal with these.

As a software engineer, I’ve been working with Git for many years1. In that time, a lot of stuff has changed. I’ve gone through three usernames (Oatmas64134->Otmas->Dev-Osmium->Muirrum), several emails, and quite a few organizations. One thing that’s been constant, however, has been the output of git config user.name. For more than six years now, that command has spat out my birth name. Up until recently, that was perfectly fine, but then I changed my name, and I started trying to scrub my deadname from as many places as I could.

Git by nature keeps a record of who made what change and when. These changelogs can be viewed by anyone who has the repository. While they can be changed, it’s usually considered bad form to change the history of a public repository. And on top of that, several organizations that I am not and will not be out to have my GitHub and see it regularly. I’ve been looking for a way to update my name across all git commits that I’ve made, but only in certain repositories.

This was an interesting problem. A few searches later and I came across this page on how to edit committer names. Scrolling down led me to this git filter-branch script

$ git filter-branch --env-filter '
WRONG_EMAIL="wrong@example.com"
NEW_NAME="New Name Value"
NEW_EMAIL="correct@example.com"

if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
	export GIT_COMMITTER_NAME="$NEW_NAME"
	export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
then
	export GIT_AUTHOR_NAME="$NEW_NAME"
	export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

This seems like a fairly simple script, and a review of the docs for git-filter-branch confirms this. What it also mentions, in a nice big “WARNING” paragraph at the top, is this:

       git filter-branch has a plethora of pitfalls that can produce
       non-obvious manglings of the intended history rewrite (and can leave
       you with little time to investigate such problems since it has such
       abysmal performance). These safety and performance issues cannot be
       backward compatibly fixed and as such, its use is not recommended.
       Please use an alternative history filtering tool such as git
       filter-repo[1]. If you still need to use git filter-branch, please
       carefully read the section called "SAFETY" (and the section called
       "PERFORMANCE") to learn about the land mines of filter-branch, and then
       vigilantly avoid as many of the hazards listed there as reasonably
       possible.

Well then. More searching led to this repo for git filter-repo. I spent some time looking through the docs, and came across the --name-callback and --email-callback arguments. These take in python code and expect a return value. I threw together this oneliner to replace any instances of my deadname with my real name:

git filter-repo --name-callback 'return name.replace(b"$deadname", b"Cara")' \
	--email-callback 'return email.replace(b"$deadname", "cara")' \
	--message-callback 'return message.replace(b"$deadname", b"Cara")'

This worked perfectly, and I am now able to update my name across all repos I want to.


  1. I made my first GitHub repository in 2014 as Oatmas64134 ↩︎


Articles from my webring

gccrs: An alternative compiler for Rust

This is a guest post from the gccrs project, at the invitation of the Rust Project, to clarify the relationship with the Rust Project and the opportunities for collaboration. gccrs is a work-in-progress alternative compiler for Rust being developed as part…

via Rust Blog November 7, 2024

Status update, October 2024

Hi! This month XDC 2024 took place in Montreal. I wasn’t there in-person, but thanks to the organizers I could still ask questions and attend workshops remotely (thanks!). As usual, XDC has been a great reminder of many things I wanted to do but which got bur…

via emersion October 21, 2024

Post-OCSP certificate revocation in the Web PKI

Introduction Today, TLS certificates in the Web public key infrastructure (PKI) have long validity: almost all remain valid for at least three months! An attacker compromising a certificate early enough in its lifetime1 keeps it compromised for months. Cer…

via Posts on Seirdy’s Home September 25, 2024

Generated by openring