Zend certified PHP/Magento developer

Rewrite and Resign git commit-history with git-filter-repo

I have an existing private git-repository (with two branches), hosted on GitHub. I plan to make it public, but I don’t want to make public the author email-address. So, the plan is to rewrite the commit-history, by replacing the <old-author-email> with the <new-author-email>, and resign the commits. Also, I want to maintain the time-stamps (this is important for me!).

So, based on extensive research I have come-up with the following steps:

  1. Clone the repository on my local machine.
  2. Create a python-3.x virtual-environment, and run pip install git-filter-repo. (source)
  3. Create a .mailmap file in the repository WORKING_DIR, with the email remapping information. (source)
  4. Run git-filter-repo --force --mailmap .mailmap. (source1, source2)
  5. Somehow resign the new-commits !!
  6. Then run git push origin <your_branch_name> --force, to rewrite the remote commit-history. (source)
    • If this step doesn’t work, I would simply delete the original Github repository; Create a new one with the same name, and then push the local-repository to it.

The above steps (until step-4), rewrite the author-email and recompute the hashes, but discard the signatures. The documentation says: (source)

Since git filter-repo calls fast-export and fast-import to do a lot of the heavy lifting, it inherits limitations from those systems … commits get rewritten meaning they will have new hashes; therefore, signatures on commits and tags cannot continue to work and instead are just removed (thus signed tags become annotated tags)

So, to resign the commits, I found the following method (source).

git filter-branch --commit-filter 'git commit-tree -S "$@";' <COMMIT>..HEAD

But using git filter-branch is not recommended (source), even by Git’s own documentation (source).

Questions:

  • And, is there a way to rewrite author-email and resign the new-commits, all using git-filter-repo?
  • And if no! then, how to rewrite the author-email over the entire commit-history and resign the new-commits? (a better way than mine!)