I commit a git repository at first time, I then regret the commit and want to revert it. I try
# git reset --hard HEAD~1
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
You just need to delete the branch you are on. You can't use
git branch -D as this has a safety check against doing this. You can use
update-ref to do this.
git update-ref -d HEAD
Do not use
rm -rf .git or anything like this as this will completely wipe your entire repository including all other branches as well as the branch that you are trying to reset.