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:
- Clone the repository on my local machine.
- Create a python-3.x virtual-environment, and run
pip install git-filter-repo
. (source) - Create a
.mailmap
file in the repositoryWORKING_DIR
, with the email remapping information. (source) - Run
git-filter-repo --force --mailmap .mailmap
. (source1, source2) - Somehow resign the new-commits !!
- 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!)