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

crates.io: development update

Since crates.io does not have releases in the classical sense, there are no release notes either. However, the crates.io team still wants to keep you all updated about the ongoing development of crates.io. This blog post is a summary of the most significa…

via Rust Blog July 29, 2024

So you want to compete with or replace open source

We are living through an interesting moment in source-available software.1 The open source movement has always had, and continues to have, a solid grounding in grassroots programmers building tools for themselves and forming communities around them. Some loo…

via Drew DeVault's blog July 16, 2024

Status update, July 2024

Hi! This month wlroots 0.18.0 has been released! This new version includes a fair share of niceties: ICC profiles, GPU reset recovery, less black screens when plugging in a monitor on Intel, a whole bunch of new protocol implementations, and much more. Thanks…

via emersion July 16, 2024

Generated by openring