It happens to every team, someone force-pushes to the repository and overwrites the branch, instead of pulling and merging changes like they should. We want to make this a thing of the past, so today we're introducing force-push protection.

Force-push protection is enabled by default for every Git repository in Codebase. Anybody attempting to overwrite a branch with git push --force will be presented with the following message:

Rejected Force Push

If a force push is really required, force-push protection can be turned off in Repository Settings, just set "Allow Force Pushes?" to "Yes - allow force pushes". Once this is done, force pushes will be allowed, but they'll be logged on the activity feed as a forced push.

Logged Force Push

The future

Initially, force-push protection is only for Git, but we'll be extending this functionality to Mercurial as soon as possible.

Currently force-push protection can only be applied to the entirety of a repository, however now we have the appropriate framework in place, we should in future be able to restrict pushing to specific branches on a per-user basis. This will allow teams to have an enforced workflow using merge-requests, or another merging strategy of their choice.

Tell us how you feel about this post?