Lab : resetting and reverting Q 5 Error

hi Team

In Lab : resetting and reverting Q5 there is a hint provided " git reset --soft HEAD-1 "
I tried this but this gives error as below


sarah (master)$
sarah (master)$ git reset --soft HEAD-1
fatal: ambiguous argument 'HEAD-1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
sarah (master)$
sarah (master)$ git status
On branch master
nothing to commit, working directory clean
sarah (master)$
sarah (master)$ git log --oneline
b452a7d (HEAD -> master) Finish story
26158b4 Revert "Add author info to stories"
f61f233 Add author info to stories
ce3d08a Add stories
sarah (master)$ git reset --soft HEAD~1
sarah (master)$

I think the answer provided in hint should be " git reset --soft HEAD~1 " and not HEAD-1

But please verify and revert.

with best regards
Pradeep Nehe

==============================

Complete output as below


sarah (master)$
sarah (master)$ git reset --soft HEAD-1
fatal: ambiguous argument 'HEAD-1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
sarah (master)$
sarah (master)$ git status
On branch master
nothing to commit, working directory clean
sarah (master)$
sarah (master)$ git log --oneline
b452a7d (HEAD -> master) Finish story
26158b4 Revert "Add author info to stories"
f61f233 Add author info to stories
ce3d08a Add stories
sarah (master)$ git reset --soft HEAD~1
sarah (master)$

Hello @ppnehe i think this will help you:
To undo the last commit, we can do the following depending on the last commit.

  • When the last commit is not the initial commit
    • No changes. i.e. Execute git reset HEAD~
  • When the last commit is the initial commit
    • Execute git update-ref -d HEAD followed by git rm -fr . git rm --cached -r . cf.