fancy
fancy

Reputation: 51383

How to apply a git revert?

I'm working on a git deploy server. I had to reset my local head back a few commits and now im trying to get the server back in sync. I get this error...

! [rejected] master -> master (non-fast-forward) error: failed to push some refs to server 
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

When I pull it just puts my local repo back before the revert...

Thanks!

Upvotes: 0

Views: 430

Answers (1)

Mark Longair
Mark Longair

Reputation: 467111

(It looks as if you've not only reset back a few revisions, but also create a new commit locally, since otherwise the error would just be "already up to date" or something similar. You can check this with git fetch origin and then gitk --all.)

If you're sure that you want to just discard the extra commits on the deploy server's master, you can do a force push with:

 git push --force origin master

Force pushing usually means that you're rewriting history in a way that may be problematic for any collaborators on the project, but I assume that since this is just a server that you push to in order to deploy, it's not one that people are cloning from. However, if my assumption is wrong, you should rethink this.

Upvotes: 1

Related Questions