Command

Git Undo Last Commit (Keep Changes) Command

The Git command to undo last commit (keep changes) is git reset --soft HEAD~1.

Quick Answer

Command
git reset --soft HEAD~1
GitCommand

Undo Last Commit (Keep Changes)

Type this command
git reset --soft HEAD~1

Removes the last commit but keeps its changes staged.

Learn More

How to undo last commit (keep changes) in Git

  1. Open the terminal or command interface for Git.
  2. Type git reset --soft HEAD~1, replace any placeholders, and run it.

Git Undo Last Commit (Keep Changes) Command

Run git reset --soft HEAD~1.

Related Commands

Frequently asked questions

What is the Git command to undo last commit (keep changes)?

Run git reset --soft HEAD~1.

Where do I type this Git command?

Type it in the terminal or command-line interface used by Git.

Does this Git command work on Mac and Windows?

Yes. The command text is the same on both platforms when the tool is installed.

Official source · How we verify