Why do force-pushes cause problems for PullRequest?

What force-pushes are

Forced pushes cause mutations of your git repository's history. These include:
git push --force
git push --force-with-lease
Though the practice is generally discouraged, from time to time you may find yourself in a situation that requires it.
One of the negative side effects of force-pushing is that it will cause workflow issues with services such as PullRequest that interact with your version control provider (such as GitHub, GitLab, or Bitbucket).

Issues resulting from force-pushes

  • Version control providers have to apply special handling of these updates, so changes are not always propagated to PullRequest and other integrated services immediately.
  • If PullRequest, or another member or your team, is actively reviewing a pull or merge request during a force-push, the code being reviewed will become outdated since it was aggregated based on the repository's git history (which has been mutated).
  • Any important information regarding issues with the code applied as a comment may be lost and unrecoverable.
Force-pushing may cause PullRequest completion time to be extended since in most cases reviewers will need to stop work and start over.

How to avoid these issues

We strongly encourage limiting force-pushes to branches which are not part of an open pull or merge request. We also recommend ensuring that no additional CI programs are processing builds at the time you force-push as it will also cause errors with those programs.
If a pull or merge request is open and a situation arises where a force-push is required, an alternative is to close your current pull or merge requests, force-push, then re-created them based on the new git history.
Last modified 4yr ago