如何修复git中第一次提交的元信息?

这是一个与How do I edit git’s history to correct an incorrect email address/name相关的问题.使用git rebase -i< first commit>,git commit –amend –author“Foo< foo@example.com\u0026gt;”和git rebase --continue,我能够修复所有提交的日志,但是第一个提交.如何修复第一次提交?
经过多次试验和错误后,发现以下配方有效:

# tag the root-most commit so we can reference it
git tag root `git rev-list HEAD | tail -1`
# check it out on its own branch
git checkout -b new-root root
# amend the commit
git commit --amend
# now you've changed the commit message, so checkout the original branch again
git checkout @{-1}
# and rebase it onto your new root commit
git rebase --onto new-root root
# then nuke the temporary branch and tag we created
git branch -d new-root
git tag -d root

对于这个答案,真正的功劳应该是#git上的毛絮.

翻译自:https://serverfault.com/questions/12918/how-do-i-fix-the-metainformation-on-the-first-commit-in-git

转载注明原文:如何修复git中第一次提交的元信息?