DEV Community

Cover image for How to undo the most recent local commits in Git?
Ankur Singh
Ankur Singh

Posted on

1 1

How to undo the most recent local commits in Git?

Step 1:

git reset HEAD~ 
Enter fullscreen mode Exit fullscreen mode

Step 2:

# Make the changes as necessary
Enter fullscreen mode Exit fullscreen mode

Step 3:

git add .
Enter fullscreen mode Exit fullscreen mode

Step 4:

git commit -c ORIG_HEAD
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay