How to Undo the Last Git Commit on Local Machine

Beda Arta
Git

For some reason, I want to undo the last git commit on my local machine, maybe because I want to add additional changes. Here are the steps that I usually follow:

  1. Run git status just to check the current status
On branch feature/permissions
nothing to commit, working tree clean
  1. To undo the last commit on local machine, run this command:
git reset --soft HEAD~1  
  1. Run git status once more to see the latest status
On branch feature/permissions
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:  check-permissions.ts

That's all! By doing this, you can add additional changes and commit again.