I commit to a git repository for the first time; I then regret the commit and want to revert it. I try
# git reset --hard HEAD~1
I get this message:
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
This commit is the first commit of the repository. Any idea how to undo git’s initial commit?
You just need to delete the branch you are on. You can’t use
git branch -Das this has a safety check against doing this. You can useupdate-refto do this.Do not use
rm -rf .gitor 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.