You can block force pushes (git push --force) on all branches—or just the default branch—of a repository.

Note: Each repository automatically inherits default settings from the organization or user that owns it. You cannot override the default setting if the repository's owner has chosen to enforce the setting on all of its repositories.

  1. As a site admin, sign in to your GitHub Enterprise instance at http(s)://[hostname]/login.

  2. In the upper-right corner of any page, click . Rocketship icon for accessing site admin settings

  3. In the search field, type the name of the repository and click Search. Site admin settings search field

  4. Select Block or Block to the default branch under Push and Pull.

    Block force pushes

The change takes effect immediately. If you change your mind later, you can easily re-allow force pushes at the same location in Site Admin.

Further reading