How do I undo my last comment in Git?

Learn how to use the “git reset” command and reset the HEAD pointer to undo your last commit.

By Lorna Jane Mitchell
September 21, 2016
Screenshot from "How to undo your last commit" Screenshot from "How to undo your last commit"

Sometimes developers using Git make a commit with the best of intentions but then later experience regret. In this video, experienced trainer Lorna Mitchell teaches you how to safely undo your newest Git commit and explains when it is appropriate to force push to the repository. Newcomers to Git will learn how to use the “git reset” command and reset their HEAD pointer so that they can continue committing without disrupting the repository.

Continue learning Git in Safari now with our Git Learning Path.

Learn faster. Dig deeper. See farther.

Join the O'Reilly online learning platform. Get a free trial today and find answers on the fly, or master something new and useful.

Learn more

Lorna Mitchell is based in Leeds, UK where she is a Developer Advocate at IBM Cloud Data Services and an experienced developer and trainer. Lorna is the accomplished author of a number of books including PHP Web Services, the Git Workbook, and PHP Master. She brings her technical expertise to audiences all over the world, dispensing guidance on a wide range of technical topics, all with a very practical slant. When she’s not busy spreading knowledge, Lorna blogs at

Post topics: Software Engineering
Post tags: Questions