A bad commit
A commit broke the site. There are two ways back: add a new commit that undoes it (revert), or move the branch back as if it never happened (reset). Choosing correctly matters when others share your history.
revert vs reset
echo "<h1>BROKEN</h1>" > index.html git commit -am "Experimental header" git revert HEAD git log --oneline cat index.html
echo "draft" > notes.txt git add . git commit -m "WIP notes" git reset HEAD~1 git status git reset --hard HEAD git log --oneline
- Already pushed or shared? Use revert.
- Only on your machine? reset is fine to tidy up.
- git reset --hard deletes uncommitted work for good — check git status first.