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).
