يتيح لك Git إعادة كتابة السجل — تعديل الالتزامات (commits)، وإعادة تحديد الأساس (rebasing)، ودمج الالتزامات (squashing)، أو إزالة الالتزامات — لتنظيف الالتزامات أو إصلاح المشاكل. إنها قوية لكن يجب القيام بها بحذر: إعادة كتابة السجل المشترك تسبب مشاكل خطيرة، لذا القواعد المتعلقة بها حاسمة.
طرق إعادة كتابة السجل
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).
