I was browsing upcoming changes in Babel today when I spotted a typo. For these kind of tiny fixes I don’t bother: I simply edit the file through GitHub UI and let it forked the repository, name the branch and propose a pull request for me.

But now the maintainer asked me to make my commit message more informative. Fair enough. This shouldn’t take long.

So I fetched a local copy of my fork, made the edit and pushed it back:

$ git clone https://github.com/kdeldycke/babel.git
$ cd ./babel
$ git checkout patch-1
$ git rebase -i HEAD~10
$ git push --force

It’s only after looking at the pull request in GitHub that I realized the last ten commits were marked as new and different, while I expected only last one to be featured as a change against master. In a word, I messed-up.

A closer inspection revealed that rebase seems to have introduced extra Committer metadata. And my confidence that it would not made me force the subsequent push.

It’s now time to untangle this mess. I first tried to realign authorship metadata on the last 10 commits (665212 being my PR’s root, i.e. the last untouched commit):

$ git filter-branch --force --env-filter '
    export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
    export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
' -- 665212..patch-1

Still, commit checksums did not returned to their original value. There must be other metadata involved.

As I wasn’t ready to waste time on doctoring each commit to find the underlying differences, I simply rebased everything to master:

$ git rebase master
$ git pull
$ git rebase origin/master
$ git push --force

It did work and my PR was now clean and tidy.