This is a git command I use quite often, so I searched a little about the different options and their effects:

CommandCommit HistoryStaging AreaWorking Directory
git reset HEAD~Removes last commitUnstages changesKeeps changes
git reset --soft HEAD~Removes last commitKeeps changes stagedKeeps changes
git reset --hard HEAD~Removes last commitDiscards all changesDiscards all changes
  • HEAD~ refers to the commit just before the current HEAD (i.e., the previous commit).

What happens when you run git reset HEAD~:

  • The branch pointer (HEAD) is moved back by one commit, undoing the latest commit from your branch history.
  • The changes from that commit are unstaged, but you can still see them in your working directory