How to undo a commit in freshly initialized repository (not pushed) : <p>I intialized a repo but now want to <a href="https://stackoverflow.com/questions/2845731/how-to-uncommit-my-last-commit-in-git">undo</a> the <strong>first</strong> (and only) commit. </p>

<p>These <a href="https://stackoverflow.com/a/2846154/5783745">three solutions</a> for undoing a commit all error because the <a href="https://stackoverflow.com/questions/12267912/git-fatal-ambiguous-argument-head-unknown-revision-or-path-not-in-the-workin">freshly created repo points to a ref that doesn't exist yet</a></p>

<p>So my question is how do I undo a commit in a repo that hasn't been pushed and hence hasn't got a ref yet? </p>

<p>Note: I have also tried <code>git commit -amend</code> without success</p>
