We have the Reject Force Push hook turned on in our Bitbucket server which is a godsend for most situations but it prevents a real need which is rebasing a topic branch that is undergoing code review in a PR. For example you might want to:
- Interactively rebase, squashing commits, fixing commit messages, etc.
- Rebase --onto another branch.
Let's focus on the first use case because that would be possible with --force-with-lease. (It expects the remote ref to be the same as on the tracking branch, and that wouldn't be the case with rebase --onto).
Can a server-side hook tell if a push is --force-with-lease vs. --force? If so then it would be an easy modification to the existing hook. If not then we would need to use an addon like Control Freak which can let you allow push --force for certain branch types but not others.