git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Checkout previous branch command not working on ​2.34.1.400
@ 2021-12-06 16:52 Will Beason
  2021-12-06 17:17 ` Eric Sunshine
  0 siblings, 1 reply; 3+ messages in thread
From: Will Beason @ 2021-12-06 16:52 UTC (permalink / raw)
  To: git

Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

I typed "git checkout -"

What did you expect to happen? (Expected behavior)

I expected the previous branch to be checked out

What happened instead? (Actual behavior)

error: pathspec '-' did not match any file(s) known to git

What's different between what you expected and what actually happened?

I expected the previously-working behavior of switching to previous branch to
work, but it didn't.

Anything else you want to add:

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.34.1.400.ga245620fadb-goog
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 5.10.46-5rodete1-amd64 #1 SMP Debian 5.10.46-5rodete1
(2021-09-28) x86_64
compiler info: gnuc: 10.3
libc info: glibc: 2.32
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]
commit-msg
post-checkout
post-commit
post-merge
pre-commit
pre-push
prepare-commit-msg


- Will Beason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Checkout previous branch command not working on ​2.34.1.400
  2021-12-06 16:52 Checkout previous branch command not working on ​2.34.1.400 Will Beason
@ 2021-12-06 17:17 ` Eric Sunshine
  2021-12-06 17:36   ` Will Beason
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sunshine @ 2021-12-06 17:17 UTC (permalink / raw)
  To: Will Beason; +Cc: Git List

On Mon, Dec 6, 2021 at 12:04 PM Will Beason <willbeason@google.com> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Checkout previous branch command not working on ​2.34.1.400
  2021-12-06 17:17 ` Eric Sunshine
@ 2021-12-06 17:36   ` Will Beason
  0 siblings, 0 replies; 3+ messages in thread
From: Will Beason @ 2021-12-06 17:36 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List

I'm going to bet you're absolutely correct. Yeah, the error message
could be clearer.

After using "git checkout [branch]" for a while, I reflexively typed
"git checkout -" and it worked again.

- Will Beason

On Mon, Dec 6, 2021 at 11:17 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Mon, Dec 6, 2021 at 12:04 PM Will Beason <willbeason@google.com> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-06 17:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 16:52 Checkout previous branch command not working on ​2.34.1.400 Will Beason
2021-12-06 17:17 ` Eric Sunshine
2021-12-06 17:36   ` Will Beason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).