From the official documentation on dealing with Protected Branches:
- Navigate to your project’s Settings ➔ Repository
- Scroll to find the Protected branches section.
- From the Branch dropdown menu, select the branch you want to protect and click Protect.
Following the steps above, you should be greeted with a box similar to this one below.
There, you can click either:
- “Allowed to force push” toggle button, or
- the orange Unprotect button
for the branch you want to force push to, e.g., master
.
If you don’t want to navigate through the navigation bars, you can also fill out this URL template:
https://gitlab.com/<USERNAME>/<PROJECTNAME>/settings/repository#js-protected-branches-settings
and replace <USERNAME>
and <PROJECTNAME>
with your specific username and project name, respectively.
Note, the “Allowed to force push” button is probably favored over un-selecting the Unprotect button because branch protection gives you additional safety from accidentally deleting your branch. But either option appears to work.
More help:
- Community discussion on force pushing on branch https://gitlab.com/gitlab-com/support-forum/issues/93
- Official documentation to do so https://docs.gitlab.com/ee/user/project/protected_branches.html