Article version: Enterprise Server 2.20

Blocking force pushes to a repository

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 enforced the setting on all of their repositories.

1. Sign in to your GitHub Enterprise Server instance at `http(s)://HOSTNAME/login`. 1. In the upper-right corner of any page, click . ![Rocketship icon for accessing site admin settings](/assets/images/enterprise/site-admin-settings/access-new-settings.png) 1. In the search field, type the name of the repository and click **Search**. ![Site admin settings search field](/assets/images/enterprise/site-admin-settings/search-for-things.png) 1. In the search results, click the name of the repository. ![Site admin settings search options](/assets/images/enterprise/site-admin-settings/click-repo.png) 1. In the upper-right corner of the page, click **Admin**. ![Admin Tools](/assets/images/enterprise/site-admin-settings/user/user-admin-tab-top.png) 1. In the left sidebar, click **Admin**. ![Admin Tools](/assets/images/enterprise/site-admin-settings/user/user-admin-tab.png) 4. Select **Block** or **Block to the default branch** under **Push and Pull**. ![Block force pushes](/assets/images/enterprise/site-admin-settings/repo/repo-block-force-pushes.png)

The change takes effect immediately. If you change your mind later, you can easily re-allow force pushes.

Further reading

Ask a human

Can't find what you're looking for?

Contact us