Any site administrator can block all force pushes (git push --force) on a GitHub Enterprise appliance.

Each repository inherits a default force push setting from the settings of the user account or organization to which it belongs. Likewise, each organization and user account inherits a default force push setting from the force push setting for the entire appliance. If you change the force push setting for the appliance, it will change for all repositories owned by all users and organizations.

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

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

  3. Advanced Settings tabIn the left sidebar, click Advanced Settings.

  4. New setting keyIn the Key field, type git.reject_force_push.

  5. In the Value field, type the desired value.

    • New setting all branches valueTo block force pushes on all branches, type all.
    • New setting default branch only valueTo block force pushes on the default branch only, type default.
  6. Policy radio buttonTo prevent this setting from being overridden by user, organization, or repository settings, select Policy.

  7. Add settingClick Add.

The change takes effect immediately. You should now see the new setting listed:

Apply setting

Further reading