Showing posts with label Git Reset. Show all posts
Showing posts with label Git Reset. Show all posts

How to Undo the Last Git Commit Locally (3 Safe Methods, 2026 Guide)

Quick answer: to undo your last local Git commit but keep the changes on disk, run git reset HEAD~1. To undo the commit and throw the changes away completely, run git reset --hard HEAD~1. Neither command touches a remote unless you push afterward.