0

I made some changes on the hotfix branch and pushed to server. Not the API will not change and I have to reset the hotfix and origin/hotfix to a certain point in code. The locla branch can easily be reset but I am not able to push it to origin because it needs me to pull first which I don't want to do it because I want to revert (lose) those changes on origin. How can I reset my origin/hotfix to a certain point?

I used git push --force origin hotfix/1.0.4 it returns

Total 0 (delta 0), reused 0 (delta 0) remote: error: denying non-fast-forward refs/heads/hotfix/1.0.4 (you should pull first) To http://ac-git/Web.ABC.git ! [remote rejected] hotfix/1.0.4 -> hotfix/1.0.4 (non-fast-forward)

Any idea how can I reset the origin/hotfix ?

Negin Basiri
  • 1,201
  • 2
  • 21
  • 45
  • it is terribly bad to change pushed history; you'll have to pull, and then patch your code to go back as a new commit; or branch fresh from your desired base commit and work from there (discarding the old branch) – guido Feb 25 '15 at 00:41

2 Answers2

1
remote: error: denying non-fast-forward refs/heads/master (you should pull first)

Was one of the first errors that ever happened to me.

It seems to happen because the remote server has been configured to reject non-fast-forward updates.

A general solution is to edit the configurations on the remote to something like:

denyNonFastForwards = false

Have you tried this link push changes without pull? Here I found further answers!

Community
  • 1
  • 1
Joey Dorrani
  • 371
  • 1
  • 1
0

The remote server seems to reject non fast forward changes, which is a good thing for the repository history consistency. So, instead of resetting the branch to an older commit, you can push changes resulting in the wanted code state (like a revert commit). Starting from the target commit/code state, issue:

git reset --soft origin/hotfix/1.0.4
git commit
git push origin hotfix/1.0.4
Julien Carsique
  • 3,789
  • 3
  • 20
  • 28