I can't find working solution for my problem:
How to remove commit in local and also in remote repository.
Here is one solution. But when I try this I can go back with reset command in my local repository. But I can't push it. The error message says:
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
But after pull my master points again to the commit that I want to remove.
Can you help?
EDIT - my try:
$ git reset --hard HEAD^1
HEAD is now at 1c50f9c good commit
$ git push -f
Total 0 (delta 0), reused 0 (delta 0)
remote: error: denying non-fast-forward refs/heads/master (you should pull first)
To E:/reps/gf.git
! [remote rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'E:/reps/gf.git'
Your remote repository likely has a setup that disallows non-fast-forward pushes on the server side. You have two options:
Contact the server administrators, explain your case, and ask them to (temporarily) rescind the no-fast-forward-push policy, with something like git config receive.denyNonFastForwards. (You will still need the -f flag to push.)
Use git revert instead of git reset, and push the resulting commit. Both the commit and its inverse will be visible, but sometimes that cannot be avoided. Unless the original commit contains sensitive data, this should be a big deal—git commits get reverted all the time. If the original commit does contain sensitive data, see option 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With