I’d like to have protected branches to which I can’t accidentally push directly. They shall usually only get changed by merging a merge request.
On the other hand, I want to be able to do priviledged things, even push to the protected branches, now and then.
Is there some way in which I can work with normal permissions usually (to protect me from myself), and in exceptional cases elevate my permissions to do more, like with “sudo”?
Nope. You either set the protection or not. What would be the point, anyone will just enable “sudo” mode permanently and won’t care.
The point would be that I know I’m making mistakes, so, no, I would not enable the sudo mode permanently. Same as I’m not always logging in as root on my own PC.
It won’t help here, but GitLab also has “admin mode”, so I can be logged in to the webUI with my normal account and then have to re-enter my password when I want to do anything that require admin access (my account has admin rights). Yet another example (but closer to the subject matter than equating to working as “root” - which I agree is a terrible idea) of a feature designed to prevent you from making mistakes.
I enabled “admin mode” quite soon after it had been implemented, because it is a good idea. But as said: it won’t help here.