如何在git中首次提交元信息?

这是一个相关的问题, 我如何编辑Git的历史logging来纠正不正确的电子邮件地址/名称 。 使用git rebase -i <first commit>git commit --amend --author "Foo <[email protected]>"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 

真正的信用应该去drizzd #git这个答案。