I've seen from Change the author and committer name and e-mail of multiple commits in Git how to change my email in my commits; however, when I try to push it, I get this error:
$ 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.
So then I tried to execute the commit-email-chang开发者_如何学运维ing-command in the remote repo and it shows me You need to run this command from the toplevel of the working tree.
All you need to do is use git push --force
to overwrite the branch in the remote repository.
Note that this is a bad idea if other people have long-term branches based the current contents of the remote repository. In that case, you shouldn't modify the history at all.
However, short term branches that are thrown away and regenerated often, and never merged back into the upstream branch (like linux-next which is automatically regenerated daily and used only for automatic testing), should be no problem at all.
精彩评论