Sorry -- I cannot relate to the existing answers to this question and also not to most questions, as it is ambiguous what is being asked and what is being accomplished by the answers. I did:
- git clone ….
- edited file "file" using my favorite editor
- git add file
- git commit file
I want to return to the state just after 2. and before 3.
If your answer contains arguments to any git command, please do not forget to explain these arguments (e.g. HEAD~32).
My question seems to be a "duplicate question". I was not shown this existing question when searching for "undo git commit". So potentially this question will also not be shown to other people searching for my search phrase (nor to me, when I need to look up the answer again). Also answers in the existing question are not explaining what HEAD^ is (neither does the current answer here).