Reputation: 29084
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?
Upvotes: 3
Views: 393
Reputation: 12914
have you tried git reset origin/master
?
or change origin/master
to a commit id if you have some not pushed commits you would like to keep.
Upvotes: 1
Reputation: 527023
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.
Upvotes: 4