Revert the first commit in a local git repository
Let’s say we have init locally a new git repository and we have done the first commit. Immediately we discover that we have made a mistake.
How can we revert the first commit of a repository ?
If we try the command git reset HEAD~
we will obtain an error: the revision is unknown.
This is because there isn’t a previous commit to come back.
So the solution is to execute the commmand:
git update-ref -d HEAD
After run it the commit will be revert.