When the "Reject Force Push" hook is enabled and the Git version is 2.11.0, all pushes to the repository fail even when the --force option is not used.
- Spin up Bitbucket Server using git v2.11.0
- Create a new repository and push an initial commit to it
- Turn the "Reject Force Push" pre-receive hook on OR setup branch permissions to prevent writing history on your branch
- Create a new commit and attempt to push it to Bitbucket Server
Push is successful.
Push is blocked by a pre-receive hook (or branch permissions).
From the git 2.11 release notes:
In order for the receiving end of "git push" to inspect the
received history and decide to reject the push, the objects sent
from the sending end need to be made available to the hook and
the mechanism for the connectivity check, and this was done
traditionally by storing the objects in the receiving repository
and letting "git gc" expire them. Instead, store the newly
received objects in a temporary area, and make them available by
reusing the alternate object store mechanism to them only while we
decide if we accept the check, and once we decide, either migrate
them to the repository or purge them immediately.
Downgrade to Git 2.10.x or older. Any version after Git 2.11.0 (including future 2.12+ releases) cannot be used with Bitbucket Server.
Bitbucket Server 4.12 will fail on startup if Git 2.11+ is detected. However, older versions of Bitbucket Server (and Stash) are not aware of the 2.11 issues (since it was released after they were), but will still be broken by them. Administrators are strongly encouraged to only upgrade to Git versions which are explicitly marked supported on our Supported Platforms for the version of the product they're running.