1

我从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-changeing-command 它向我展示了You need to run this command from the toplevel of the working tree.

4

1 回答 1

2

您需要做的就是使用git push --force覆盖远程存储库中的分支。

请注意,如果其他人拥有基于远程存储库当前内容的长期分支,则这是一个坏主意。在这种情况下,您根本不应该修改历史记录。

但是,经常被丢弃和重新生成的短期分支,并且从未合并回上游分支(例如linux-next,它每天自动重新生成并仅用于自动测试),应该完全没有问题。

于 2011-01-17T21:49:07.287 回答