我从Change the author and committer name and e-mail of multiple commits in Git看到如何在我的提交中更改我的电子邮件;但是,当我试图推动它时,我收到了这个错误:
$ git push production master
To git@<remote_server>
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@<remote_server>
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
然后我尝试在远程仓库中执行commit-email-changing-command并向我显示You need to run this command from the toplevel of the working tree.
答案 0 :(得分:2)
您需要做的就是使用git push --force
覆盖远程存储库中的分支。
请注意,如果其他人根据远程存储库的当前内容拥有长期分支,则这是一个错误的想法。在这种情况下,您根本不应修改历史记录。
然而,经常抛弃和重新生成的短期分支,从未合并回上游分支(如linux-next,每天自动重新生成并仅用于自动测试)应该没有问题