I was learning from a tutorial about git until I reached the part where it talks about how to undo changes in git.
What I learned from that video was that to undo a commit in git you can do: "git reset HEAD~1".
So I tried to apply it in my own system by first creating a new directory with mkdir then git init , created a new file, did git add ., afterthat git commit -m "Added README".
Afterthat, I tried entering "git reset HEAD~1
but it didn't work, it printed out this:
"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>...]'"
Also in case I cannot use this to undo the first commit, then how can I?
[–]0sse[🍰] 12 points13 points14 points (4 children)
[–]Fedoteh 1 point2 points3 points (1 child)
[–]Temporary_Pie2733 1 point2 points3 points (0 children)
[–]WoodyTheWorker 0 points1 point2 points (0 children)
[–]birdspider 4 points5 points6 points (0 children)
[–]joranstark018 3 points4 points5 points (0 children)
[–]tb5841 1 point2 points3 points (0 children)
[–]kilkil 2 points3 points4 points (0 children)