I created the first commit of my project, but forgot to ignore node_modules.
I tried this solution to cancel the commit. However, it returns me this (sorry, virtual machine without copy/paste capacity):

As you can see in the screenshot above, it is not capable of doing what I expected. (red lines to isolate commands and help reading)
How can I cancel latest commit considering that it is the very first commit ?
You don't need to remove the commit. You can remove the node modules, edit the .gitignore and amend the changes to the last commit (which is also the first in your case):
# changes
git commit --amend
git push -f
If you insist to remove the commit, you can run
git update-ref -d HEAD
git push -f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With