"D. Ben Knoble" <ben…@gmail.com> writes:
>> I just wanted to update one of my branches to one of my devel branches and
>> did a git reset without the hard and at the end it gives me:
>
> [a large diff between HEAD and working tree]
>
> Here a simple "git restore ." would restore the working tree to match
> the index (which should be equivalent to HEAD), right?
Everything in the current index, yes, but I am not sure about the
paths that got removed from the index (i.e., the commit you resetted
to did not have them, but the index and the working tree before you
ran "git reset" did have them). Wouldn't they become untracked cruft
left in the working tree? When you try to the "git checkout" back
to the state that have them tracked, the command may refuse to
overwrite them.
If you said 'git reset $another' by mistake, when you wanted to say
'git reset --hard $another', which actually have happened to me a
few times,
$ git reset @{1} ;# go back to where I was
$ git reset --hard @{1} ;# go back there again, with --hard
is how I would recover. With the first "reset @{1}" the index would
match what is in the working tree (so you resurrect the index
entries for the leftover files in the working tree), and then "reset
--hard @{1}" goes back to where you wanted to go, but with "--hard",
the paths that were in the commit you were on but not in the commit
you are moving to now gets removed correctly.