Git позволяет переписывать историю — исправлять, выполнять rebase, squashing или удалять коммиты — для очистки коммитов или решения проблем. Это мощный инструмент, но использовать его нужно осторожно: переписывание опубликованной истории вызывает серьезные проблемы, поэтому правила вокруг этого критически важны.
Способы переписывания истории
git commit --amend → modify the most recent commit (message or content)
git rebase -i → squash, reword, reorder, edit, drop commits (interactive)
git rebase <branch> → replay commits onto another base (linear history)
git reset → move the branch pointer (discard/uncommit)
git filter-repo → rewrite MANY commits (remove a file/secret from all history)
→ All of these change commit HASHES (rewriting = creating new, different commits).
