Yesterday I created a commit to the local master branch and pushed it to the GitLab server by accident. Instead this was supposed to go in a separate branch, then pushed. I had to create a new local branch, reset the local master branch, unprotect it, force-push, and protect it again. Then I could push my new branch normally. The build server had already taken my commit and did something with it.
We use a convention that the master branch only contains merges from other feature or bugfix branches. We do code reviews when merging something into master. Since I am the project owner, I am allowed to push anything to the master branch, even though it’s protected.
Is there an option to restrict a certain branch for merges only? In case something needs to be fixed, this flag could temporarily be removed like the protection altogether. But at least it would protect the branch from accidential commits by authorised users.