Rules for force pushing

From the Lifecycle of a pull request

In order to keep the commit history intact, please avoid squashing or amending history and then force-pushing to the PR. Reviewers often want to look at individual commits.

Why is this not enforced? This seems to happen a bit too often and makes reviewing hard.
The commits are squashed when merged anyway, so it’s not like this contributes to the commit count.

The please leads me to believe that this is only a plea, not a requirement. At least that’s my guess.


I don’t think we can enforce it. Contributors would be force pushing to their own fork, which is outside of our ability to restrict things.

1 Like

I was mostly thinking about asking them not to do that without a proper reason, currently we don’t. I don’t think force pushing is necessary if you’re not merging two branches. (I’ve had some trouble recently fixing a merge conflict in VS Code)

Normally we ask people not to do it after they’ve done it. How would you propose asking them before, ideally without offending people who have either never done it, or who did it once, are still embarrassed about it, and are now even more offended by being reminded every time they start a new contribution?


Not always as far as I can tell, so I would like more core developers to be aware of this, point this out to new contributers and don’t do it themselves.

1 Like

It has been suggested multiple times before on various (non-official I think?) channels that github add the ability to block force pushing to branches that are part of a PR. Maybe if the CPython project asks for this feature, the chance of this being added increases? The pain points with this are well known, but maybe the voices just aren’t loud enough.

1 Like

Really, GitHub just needs a better review interface such that force-pushes aren’t a problem. For work, we use a review tool on top of GitHub that handles them gracefully (and usefully), and force-pushes are a common part of our workflow. Even in the cpython project there are times where a force-push is the correct answer, but the facts that we use squash merges and that it’s really easy for people who don’t have a full grasp on what they’re doing to mess up a force-push mean that it’s usually better to just ask people not to use them.