Any push to "branch protected" master branch rejected by gitea (no whitelist enabled) #2443

Closed
opened 2025-11-02 04:36:19 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @bs-git on GitHub (Oct 24, 2018).

Description

If "Branch force push protection" is enabled and no whitelist user are set, the owner (i guess also admin) user assigned to the project can no longer push to the repository at all (even if not forcing the push)

...>git push
Username for 'https://try.gitea.io': g6657217@nwytg.net
Password for 'https://g6657217@nwytg.net@try.gitea.io':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 247 bytes | 247.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Gitea: protected branch master can not be pushed to
To https://try.gitea.io/g6657217/testpush.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://try.gitea.io/g6657217/testpush.git'

Screenshots

image

Originally created by @bs-git on GitHub (Oct 24, 2018). - Gitea version (or commit ref): 1.5.2 - Git version: 2.19.1.windows.1 - Operating system: Windows - Can you reproduce the bug at https://try.gitea.io: - [ X] Yes (provide example URL) https://try.gitea.io/g6657217/testpush.git ## Description If "Branch force push protection" is enabled and no whitelist user are set, the owner (i guess also admin) user assigned to the project can no longer push to the repository at all (even if not forcing the push) ``` ...>git push Username for 'https://try.gitea.io': g6657217@nwytg.net Password for 'https://g6657217@nwytg.net@try.gitea.io': Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Writing objects: 100% (3/3), 247 bytes | 247.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: Gitea: protected branch master can not be pushed to To https://try.gitea.io/g6657217/testpush.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://try.gitea.io/g6657217/testpush.git' ``` ## Screenshots ![image](https://user-images.githubusercontent.com/15813528/47413793-8e16ca00-d76f-11e8-83cc-330a5cbd5ea8.png)
GiteaMirror added the type/question label 2025-11-02 04:36:19 -06:00
Author
Owner

@SagePtr commented on GitHub (Oct 24, 2018):

I think it's feature, not a bug. On github there is separate option "apply protected branch restriction to administrators too", on Gitea there is whitelist where administrators can be added to be able to push directly. No need in separate option because it can easily be done by whitelisting.

@SagePtr commented on GitHub (Oct 24, 2018): I think it's feature, not a bug. On github there is separate option "apply protected branch restriction to administrators too", on Gitea there is whitelist where administrators can be added to be able to push directly. No need in separate option because it can easily be done by whitelisting.
Author
Owner

@bs-git commented on GitHub (Oct 24, 2018):

So: this is effectily a "prohibit push to master" switch - either I allow (whitelist) a user so force push is also allowed for the user -or- the user can not push at all to master. I guess this was not intended by the switch?

I tried to read the code of the corresponding pushes, and it reads like it was intended to prevent any non "Admin" users from force pushing, checking the users role for the repository - which makes much more sense. But my web/go skills do not allow me to dig further into the issue.

@bs-git commented on GitHub (Oct 24, 2018): So: this is effectily a "prohibit push to master" switch - either I allow (whitelist) a user so force push is also allowed for the user -or- the user can not push at all to master. I guess this was not intended by the switch? I tried to read the code of the corresponding pushes, and it reads like it was intended to prevent any non "Admin" users from force pushing, checking the users role for the repository - which makes much more sense. But my web/go skills do not allow me to dig further into the issue.
Author
Owner

@lafriks commented on GitHub (Oct 24, 2018):

It is intended behaviour that if no user/team is whitelisted only merges through pull requests are allowed. Force pushes should not be allowed also for whitelisted users

@lafriks commented on GitHub (Oct 24, 2018): It is intended behaviour that if no user/team is whitelisted only merges through pull requests are allowed. Force pushes should not be allowed also for whitelisted users
Author
Owner

@bs-git commented on GitHub (Oct 25, 2018):

Thank you for your clarification. I tried that and it worked as you described. This behavior is a little bit inconvinient (add all user to allow simple push) - but manageable. I thought it was possible to only disable force push without managing a white list from the description in the web page.

You may close the issue, thank you.

@bs-git commented on GitHub (Oct 25, 2018): Thank you for your clarification. I tried that and it worked as you described. This behavior is a little bit inconvinient (add all user to allow simple push) - but manageable. I thought it was possible to only disable force push without managing a white list from the description in the web page. You may close the issue, thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2443