I accidentally added some files using git add . . I would like to remove the changes using git reset --hard. When I type so, I get this error message.
fatal: Failed to resolve 'HEAD' as a valid ref
I tried typing git reset --hard HEAD^. Still not able to solve it.
How do I solve it?
It sounds like you’re trying to construct the initial commit in a newly created repo.
Since you haven’t actually committed anything yet, you can just start over by removing the
.gitdirectory and runninggit initagain.Alternatively, you can try
git rm --cached .to remove the files from the index.