DEV Community

Discussion on: How to undo the last commit

Collapse
 
wilkinson profile image
wilkinson

This is the safest option if you want to preserve the changes you made but simply need to fix the commit message or add more changes before committing again.

Use the following command:

git reset --soft HEAD~
This command:

Uses git reset to modify the HEAD, which points to the latest commit.
The --soft flag tells Git to keep the changes made in the last commit as unstaged changes in your working directory.
HEAD~ refers to the parent commit of the current HEAD, effectively undoing the last commit.
Join the online community of geometry dash lite! Millions of players share their creations, challenges, and experiences, fostering a passionate atmosphere.