When is it fine to change history?

5.4.5. When is it fine to change history?#

Sensitive data

Avoid rewriting history:

It breaks collaboration, reproducibility, and the ability to track changes.

Never change shared history:

Rewriting history that is already on the remote repository breaks the workflow and requires a force push and manual cleanup by collaborators.

Exception 1: Critical need:

It’s acceptable for necessary actions like removing sensitive data.

Exception 2 optional: Local changes only:

It is generally fine to change history that has not yet been pushed (e.g., squashing commits on a local branch).