tj / git-extras

GIT utilities -- repo summary, repl, changelog population, author commit percentages and more
MIT License
17.28k stars 1.21k forks source link

git undo should work on first commit too #688

Open pathikrit opened 6 years ago

pathikrit commented 6 years ago

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
spacewander commented 6 years ago

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

vr8hub commented 4 years ago

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.

spacewander commented 4 years ago

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