Poems Fiasco 12


I am on question 12
I am trying to delete my latest commit with the command "git reset SHA-number" but when i use the "git log " command the latest commit is still there ???
Am I misunderstanding something ?


Are you using git reset first 7 digits/letters of the commit BEFORE the one you want to delete?


And were there any error messages? If so, that's telling you what is wrong.

As you can see below, what you describe will move you to the specified commit:

$ git log --oneline
50b7922 commit 2
409549d commit 1
$ git reset 409549d
$ git log --oneline
409549d commit 1

Working directory remains unchanged by the reset unless you add the option --hard (be careful with this)
And if you want to remove untracked files you can do this with git clean -f (again, be careful, use git clean -n first to see what it would remove, see git clean --help for what those options do)

The commits weren't deleted though, you just moved HEAD to an earlier commit. You can find the old commits again with git reflog

If you just want to change the latest commit (and you haven't pushed to anywhere yet) then you can commit with --amend to replace the last commit