Skip to main content

Command Palette

Search for a command to run...

How to git soft reset last commit

Published
1 min read

git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.

git reset --soft HEAD^  // going back to one commit

or

git reset --soft HEAD~1 // equivalent to "^" and going back one commits

When using git reset –soft HEAD~1 you will remove the last 1 commits (previous commit) from the current branch and when you run status the then you will see your changes in the working tree.