Identify Bitbucket Data Center projects and repositories with Reject Force Push hook enabled

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This article shows you how to identify projects and repositories with the Reject Force Push hook enabled.

  • The information in this document is presented as-is.

  • Atlassian does not guarantee that the information is correct or fit for any purpose.

  • Atlassian will not provide any support whatsoever regarding the information in this document and will not answer support requests raised in relation to it.

If you are facing issues with commits to your repositories on Bitbucket Data Center being rejected when pushing using the --force option in Git, you may want to know which projects and repositories have the Reject Force Push hook (which is a built-in hook in Bitbucket Data Center) enabled, so that you can turn off the hook to enable force pushing. This article describes how to obtain that information.

Solution

The Reject Force Push hook can be enabled on two levels — either on the individual repository level or on the project level, allowing it to work on all repositories in a project.

Finding repositories that have the hook enabled explicitly

You can run the following SQL query on your backend database to find repositories that have the hook enabled explicitly.

Note: The query has been tested with PostgreSQL and may need adapting to work with your RDBMS.

SELECT r.id as repository_id, r.slug as repository_slug, r.name as repository_name, p.name as project_name, p.project_key as project_key FROM repository r, sta_repo_hook srh, project p WHERE p.id=r.project_id AND srh.repository_id=r.id AND srh.hook_key='com.atlassian.bitbucket.server.bitbucket-bundled-hooks:force-push-hook' AND srh.is_enabled=true AND srh.repository_id is not null;

Finding projects that have the hook enabled

To find projects with the hook enabled, you can run the following SQL query on your backend database. Keep in mind that a repository may have the hook explicitly turned off even though it is enabled in the project it is part of.

Note: The query has been tested with PostgreSQL and may need adapting to work with your RDBMS.

SELECT p.name as project_name, p.project_key as project_key FROM sta_repo_hook srh, project p WHERE srh.project_id=p.id AND srh.hook_key='com.atlassian.bitbucket.server.bitbucket-bundled-hooks:force-push-hook' AND srh.is_enabled=true AND srh.project_id is not null;

Updated on May 15, 2025

Still need help?

The Atlassian Community is here for you.