Git reset –hard and push to remote repository

If forcing a push doesn’t help (git push --force origin or git push --force origin master should be enough), it might mean that the remote server is refusing non fast-forward pushes, via either receive.denyNonFastForwards config variable (see git config manpage for description), or via an update/pre-receive hook.

With older Git you can work around that restriction by deleting git push origin :master (note the : before branch name) and then re-creating git push origin master given branch.

If you can’t change this, then the only solution would be instead of rewriting history to create a commit reverting changes in D-E-F:

A-B-C-D-E-F-[(D-E-F)^-1]   master

A-B-C-D-E-F                origin/master

Leave a Comment