Rebasing old commits for trans people

Gabi
2 min readMar 8, 2023

--

Hello, my name is Gabrielle, and I’m a transgender person, so it does mean that I changed my name, so here I want to present some techniques to rebase your old commits into new ones with your real name!

You can either rebase or filter-branch. The filter-branch is legacy but still can be helpful; the central command is:

$ git filter-branch \
-f \
--env-filter \
"GIT_AUTHOR_NAME='Gabrielle Guimarães de Oliveira'; GIT_AUTHOR_EMAIL='gabrielle1guim@gmail.com'; \
GIT_COMMITTER_NAME='Gabrielle Guimarães de Oliveira'; GIT_COMMITTER_EMAIL='gabrielle1guim@gmail.com';" \
HEAD

This command basically rewrites your commit history for the repo replacing all author and commiter names and emails. The git history has 2 kinds of “authors”, the commit author itself, that’s your git name and email… and the commiter, who committed, and will appear separately on github if they’re different.

Now we have the rebase commit too, but it’s a little bit harder and for codebases that you don’t have the majority of the commits, you can do it like this:

$ git rebase \
--committer-date-is-author-date \
--gpg-sign \
--root \
-i \
HEAD~$commit_history_count

So you’ll have the rebase interface and you can rename your name and author like this:

$ git config user.name "Gabrielle Guimarães de Oliveira"
$ git config user.email "gabrielle1guim@gmail.com"

After that amend the commit with your changes like:

$ git commit --amend --reset-author --no-edit --no-gpg-sign

And return your name to the maintainer's name and email, because this will be used on the commiters name and email:

$ git config user.name "Gabrielle Guimarães de Oliveira"
$ git config user.email "gabrielle1guim@gmail.com"

That’s it, byte bye 👋

--

--

Gabi
Gabi

Written by Gabi

I'm a girl who likes functional programming