Git låter dig skriva om historik — ändra, rebasera, squasha eller ta bort commits — för att städa upp commits eller fixa problem. Det är kraftfullt men måste göras försiktigt: att skriva om delad historik orsakar allvarliga problem, så reglerna omkring det är kritiska.
Sätt att skriva om historik
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).
