Gitを使うと、履歴を書き直すことができます。コミットを修正、リベース、スカッシュ、または削除してコミットをクリーンアップしたり問題を修正できます。これは強力ですが、慎重に行う必要があります。共有履歴を書き直すと深刻な問題が発生するため、その周辺のルールは重要です。
履歴を書き直す方法
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).
