Git ให้คุณเขียนประวัติใหม่ — amend, rebase, squash หรือลบ commit — เพื่อจัดระเบียบ commit หรือแก้ปัญหา มันทรงพลังแต่ต้องทำอย่างระมัดระวัง: การเขียนประวัติที่แชร์แล้วใหม่ก่อให้เกิดปัญหาร้ายแรง ดังนั้นกฎเกณฑ์เกี่ยวกับมันจึงสำคัญยิ่ง
วิธีเขียนประวัติใหม่
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).
