Git आपको history rewrite करने देता है — commits को amend, rebase, squash, या remove करना — commits को साफ़ करने या समस्याओं को ठीक करने के लिए। यह शक्तिशाली है लेकिन सावधानी से किया जाना चाहिए: साझा history को rewrite करना गंभीर समस्याएँ पैदा करता है, इसलिए इसके आसपास के नियम महत्वपूर्ण हैं।
History rewrite करने के तरीके
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).
