Git membolehkan anda menulis semula sejarah — meminda (amend), rebase, squash, atau membuang commit — untuk membersihkan commit atau membaiki masalah. Ia berkuasa tetapi mesti dilakukan dengan berhati-hati: menulis semula sejarah yang dikongsi menyebabkan masalah serius, jadi peraturan di sekelilingnya adalah kritikal.
Cara menulis semula sejarah
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).
