0

I am using GitLab. When I pushed up to prod last time, I later realized that there are many bugs. So, I git reset --hard kjh35kh3kh4k2h4k2h4.... to the earlier working commit. But now when I am trying to push it up to GitLab I am getting error master -> master (non-fast-forward) because hint:

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.

I tried to git push -f origin master, but than I get a different error GitLab: You are not allowed to force push code to a protected branch on this project. I do understand why it is happening, but how do I fix this cleanly? Should I git reset --hard kjh35kh3kh4k2h4k2h4.... on GitLab as well, if so how do I do that?

Guntar
  • 473
  • 8
  • 23
  • I think your remote branch is used by other Dev's as well and so if you try to force push your changes to remote ,it will break other's code when they pull from remote. You can instead try to `git revert` to revert the commits. – Dev-vruper Jan 27 '21 at 15:48
  • Hmm.., I am the only dev for the account. My staging server is the other only connection to the my GitLab account. Also, It looks that, once I `reset --hard` it removed the very last commit where I had the bugs, so if I run `git revert` , to what commit should I revert? – Guntar Jan 27 '21 at 15:55
  • You shouldn't use `git reset --hard` if you want to run `git revert` .Just try running below on your branch if you want to revert only a single commit which had bugs , you can use `git revert ` . Also check this : https://stackoverflow.com/a/4114122/6309111 – Dev-vruper Jan 27 '21 at 16:06

0 Answers0