On Wed, May 8, 2019 at 1:31 AM Emily Shaffer <emilyshaffer@xxxxxxxxxx> wrote: > > > I found myself in a situation where I had accidentally > > > staged all my changes to tracked files (I think resulting from a stash > > > pop which generated a merge conflict?) and didn't see a good way to > > > unstage everything using restore. > > > > > > I tried out `git restore --staged *` and it tried to restore every build > > > artifact in my working tree, all of which should be ignored, made a lot of > > > noisy errors, and left me with my changes still staged. > > > > For the record, "git restore --staged :/" should do the trick and it > > is documented as an example (but without --staged). > > Yeah, this worked, and today I also noted `git restore --staged .` > works, as does Junio's suggestion on the other mail (`git restore > --staged revision.\*`), and quoting the * (`git restore --staged '*'`). > So maybe I didn't think outside the box enough before mailing :) No it's good. It actually got me thinking. Actually I take that back. It's bad, I'm quite stuck at thinking here :D > > Either way. I think you raise a good point about "*" (or patterns > > matching more than expected in general). I need to sleep on it and see > > if the old way of handling pattern matching failure is still a good > > way to go. > > I think it's worth considering, especially as `git reset HEAD *` and > `git reset HEAD` both work. (`git restore --staged` complains that it > hasn't got any paths, but reset seems to figure you just mean > everything.) It was a surprising failure to me coming away from years of > using reset. Yeah I agree that doing it the "git reset" way makes sense for --staged because shell expansion is tied to worktree files, and --staged is completely disconnected from worktree. Shell expansion cannot get this case right, no point punishing the user because of it. My problem is "what about the other two cases, --worktree alone or --worktree with --staged (iow do we care about consistency)? what about git-checkout? does the old way even make sense for git-checkout? any better way to do if the reason behind is still valid?". I obviously haven't worked it all out yet. -- Duy