git-extras icon indicating copy to clipboard operation
git-extras copied to clipboard

git undo should work on first commit too

Open pathikrit opened this issue 6 years ago • 3 comments

It works fine except on the first commit it gives this error:

> git undo
fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

I think it should do this for the first commit:

git update-ref -d HEAD

pathikrit avatar Dec 17 '17 09:12 pathikrit

@pathikrit Good point. Would you submit a pull request? Thanks!

spacewander avatar Dec 17 '17 09:12 spacewander

I came here to make this very point (although about "back"). I don't know how to tell there's only one commit, but I'll see if I can figure it out and file a PR.

Idle curiosity: why do both "back" and "undo" exist? Isn't "undo" sufficient, as it covers both soft and hard resets? It seems confusing to have both.

vr8hub avatar Feb 22 '20 17:02 vr8hub

@vr8hub Look like a legacy issue. Now I deprecate the git-back in https://github.com/tj/git-extras/pull/820.

spacewander avatar Feb 23 '20 03:02 spacewander