Git آپ کو تاریخ کو دوبارہ لکھنے کی صلاحیت دیتا ہے — commits کو ترمیم کرنا، rebase کرنا، squash کرنا، یا ہٹانا — تاکہ commits کو صاف کیا جا سکے یا مسائل کو ٹھیک کیا جا سکے۔ یہ طاقتور ہے لیکن احتیاط سے کرنا چاہیے: shared تاریخ کو دوبارہ لکھنے سے سنگین مسائل پیدا ہوتے ہیں، اس لیے اس کے قوانین انتہائی اہم ہیں۔
تاریخ کو دوبارہ لکھنے کے طریقے
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).
