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 .git directory and running git init again.
Alternatively, you can try git rm --cached . to remove the files from the index.
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