Git તમને ઈતિહાસ ફરીથી લખવા દે છે — કમિટ્સમાં સુધારો કરવો, rebase કરવો, squash કરવો, અથવા કમિટ્સ દૂર કરવો — કમિટ્સને સાફ કરવા અથવા સમસ્યાઓ ઠીક કરવા માટે. તે શક્તિશાળી છે પણ તે સાવચેતીથી કરવું આવશ્યક છે: શેર કરવામાં આવેલ ઈતિહાસ ફરીથી લખવાથી ગંભીર સમસ્યાઓ ઊભી થાય છે, તેથી તેની આસપાસના નિયમો ગણતરીમાં છે.
ઈતિહાસ ફરીથી લખવાની રીતો
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).
