Re: Checkout previous branch command not working on ​2.34.1.400

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 6, 2021 at 12:04 PM Will Beason <willbeason@xxxxxxxxxx> wrote:
> I typed "git checkout -"
> error: pathspec '-' did not match any file(s) known to git
>
> I expected the previously-working behavior of switching to previous branch to
> work, but it didn't.

If I recall correctly, for `-` to work it consults the reflog, but if
the reflog has been cleared or expired, it won't be able to determine
the previous branch. For instance, try this:

    % git init foo
    % cd foo
    % echo data >data
    % git add data
    % git commit -m data
    % git checkout -b other
    % git checkout -
    % git reflog expire --expire=now --all
    % git checkout -
    error: pathspec '-' did not match any file(s) known to git

So, this is probably expected behavior, though the error message isn't
very helpful and perhaps could be improved.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux