Git มีหลายวิธีในการ undo การเปลี่ยนแปลง ขึ้นอยู่กับสถานการณ์ — การทิ้งการเปลี่ยนแปลงที่ยังไม่ได้ commit, การ unstage, การ amend commit ล่าสุด, การ revert commit หรือการ reset การรู้เครื่องมือที่ถูกต้องสำหรับแต่ละสถานการณ์เป็นทักษะเชิงปฏิบัติที่สำคัญและมีค่า
undo การเปลี่ยนแปลงที่ยังไม่ได้ commit (working directory)
git restore <file> # discard unstaged changes to a file (revert to last commit)
git checkout -- <file> # older equivalent
git restore . # discard ALL unstaged changes (careful!)
git clean -fd
