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.
A space for AI engineers to learn, share, and geek out — covering everything from LLMs and agents to the tools and tricks that make building with AI easier.
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)
Subscribe to:
Posts (Atom)