about git push -f #2756

Closed
opened 2025-11-02 04:46:52 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @mojie126 on GitHub (Jan 15, 2019).

Wishing to increase the authority to control compulsory push restrictions

Originally created by @mojie126 on GitHub (Jan 15, 2019). Wishing to increase the authority to control compulsory push restrictions
GiteaMirror added the issue/confirmedtype/enhancementissue/needs-feedback labels 2025-11-02 04:46:52 -06:00
Author
Owner

@zeripath commented on GitHub (Jan 15, 2019):

It's not quite clear what you're asking. Gitea has protected branches so only certain users can push to that branch. Are you talking about adding a git hook for push - as in an arbitrary script that will check a commit and ensure that it passes some test?

OK, well obviously we can't produce a UI for that - it would mean allowing users to arbitrarily upload scripts that would be run on push. If you are the administrator and owner of the gitea server you should be able to edit the repository on the filesystem to add such a git hook - however remember that will be run during pushes so could lock the system.

Another option is to use the Gitea webhook system - the push will be accepted and then a webhook will be called which could then checkout the pushed commits and do the tests - it could then comment back on a PR or automatically push on to the master.

@zeripath commented on GitHub (Jan 15, 2019): It's not quite clear what you're asking. Gitea has protected branches so only certain users can push to that branch. Are you talking about adding a git hook for push - as in an arbitrary script that will check a commit and ensure that it passes some test? OK, well obviously we can't produce a UI for that - it would mean allowing users to arbitrarily upload scripts that would be run on push. If you are the administrator and owner of the gitea server you should be able to edit the repository on the filesystem to add such a git hook - however remember that will be run during pushes so could lock the system. Another option is to use the Gitea webhook system - the push will be accepted and then a webhook will be called which could then checkout the pushed commits and do the tests - it could then comment back on a PR or automatically push on to the master.
Author
Owner

@lunny commented on GitHub (Jan 16, 2019):

@zeripath I think he means we should add an option on protected branch to disallow users who have push permission to force push. @mojie126 Is that your issue?

@lunny commented on GitHub (Jan 16, 2019): @zeripath I think he means we should add an option on protected branch to disallow users who have push permission to force push. @mojie126 Is that your issue?
Author
Owner

@mojie126 commented on GitHub (Jan 16, 2019):

是的,限制强制推送,可以控制谁能强制推送...

@mojie126 commented on GitHub (Jan 16, 2019): 是的,限制强制推送,可以控制谁能强制推送...
Author
Owner

@stale[bot] commented on GitHub (Mar 17, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Mar 17, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@lafriks commented on GitHub (Mar 17, 2019):

But when setting protected branch it will already be protected from forced push even if set that user are allowed to do push to that branch

@lafriks commented on GitHub (Mar 17, 2019): But when setting protected branch it will already be protected from forced push even if set that user are allowed to do push to that branch
Author
Owner

@lunny commented on GitHub (Mar 18, 2019):

@lafriks I think @mojie126 means he want to give somebody push permission but cannot force push. Currently gitea didn't split them as two options.

@lunny commented on GitHub (Mar 18, 2019): @lafriks I think @mojie126 means he want to give somebody push permission but cannot force push. Currently gitea didn't split them as two options.
Author
Owner

@lafriks commented on GitHub (Mar 27, 2019):

But it already works this way. If I specify branch protection and whitelist user who can push to that branch that user will be able to push new commits but won't be able to force push

@lafriks commented on GitHub (Mar 27, 2019): But it already works this way. If I specify branch protection and whitelist user who can push to that branch that user will be able to push new commits but won't be able to force push
Author
Owner

@0x5c commented on GitHub (Apr 5, 2019):

Could it be that the OP is asking for a repository setting? Ie: blanket denying of force-pushes

@0x5c commented on GitHub (Apr 5, 2019): Could it be that the OP is asking for a repository setting? Ie: blanket denying of force-pushes
Author
Owner

@stale[bot] commented on GitHub (Jun 4, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jun 4, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@davidsvantesson commented on GitHub (Oct 21, 2019):

I think this would be solved with the combination of setting writers as push whitelist (similar as suggested in #8288) and wildcard branch protection (#2529). Then you can disable force pushing of the complete repository but still allow normal pushes.

@davidsvantesson commented on GitHub (Oct 21, 2019): I think this would be solved with the combination of setting _writers_ as push whitelist (similar as suggested in #8288) and wildcard branch protection (#2529). Then you can disable force pushing of the complete repository but still allow normal pushes.
Author
Owner

@lunny commented on GitHub (Nov 2, 2019):

How to allow someone could push but cannot force push then?

@lunny commented on GitHub (Nov 2, 2019): How to allow someone could push but cannot force push then?
Author
Owner

@davidsvantesson commented on GitHub (Nov 16, 2019):

There is already a database element for this; CanPush in ProtectedBranch. Currently it is always false (not used in any way)

@davidsvantesson commented on GitHub (Nov 16, 2019): There is already a database element for this; `CanPush` in `ProtectedBranch`. Currently it is always false (not used in any way)
Author
Owner

@davidsvantesson commented on GitHub (Nov 17, 2019):

What seem to be wanted here (google translated from Chinese):

Yes, limit forced push, you can control who can force push...

I don't see the point of enabling force pushing for everyone to a protected branch (that would be like not protecting the branch). So it does only make sense in combination of a whitelist. And I suppose it should be different whitelists for who can push normal and who can force push? What is the use case here?

@davidsvantesson commented on GitHub (Nov 17, 2019): What seem to be wanted here (google translated from Chinese): > Yes, limit forced push, you can control who can force push... I don't see the point of enabling force pushing for everyone to a protected branch (that would be like not protecting the branch). So it does only make sense in combination of a whitelist. And I suppose it should be different whitelists for who can push normal and who can force push? What is the use case here?
Author
Owner

@mrsdizzie commented on GitHub (Sep 8, 2020):

closing per lack of feedback

@mrsdizzie commented on GitHub (Sep 8, 2020): closing per lack of feedback
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2756