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,305
  • 2
  • 26
  • 47
  • 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

1 Answers1

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,915
  • 3
  • 22
  • 28