On Deadnames and GitPosted
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="email@example.com" NEW_NAME="New Name Value" NEW_EMAIL="firstname.lastname@example.org" 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. 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
--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.
I made my first GitHub repository in 2014 as Oatmas64134 ↩