{"thread":{"id":"57039","subject":"Checkout previous branch command not working on ​2.34.1.400","startedAt":"2021-12-06T17:04:21Z","lastAt":"2021-12-06T17:37:15Z","messageCount":3,"participants":["Will Beason","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"443170","messageId":"CAO6o7kKXZg37ydC145yf5uZt+tsKdYADnVfinO0sHAN=cHo-FA@mail.gmail.com","threadId":"57039","inReplyTo":null,"subject":"Checkout previous branch command not working on ​2.34.1.400","fromName":"Will Beason","fromEmail":"willbeason@google.com","sentAt":"2021-12-06T16:52:20Z","receivedAt":"2021-12-06T17:04:21Z","isPatch":false,"sender":{"key":"willbeason@google.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\nI typed \"git checkout -\"\n\nWhat did you expect to happen? (Expected behavior)\n\nI expected the previous branch to be checked out\n\nWhat happened instead? (Actual behavior)\n\nerror: pathspec '-' did not match any file(s) known to git\n\nWhat's different between what you expected and what actually happened?\n\nI expected the previously-working behavior of switching to previous branch to\nwork, but it didn't.\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.34.1.400.ga245620fadb-goog\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.10.46-5rodete1-amd64 #1 SMP Debian 5.10.46-5rodete1\n(2021-09-28) x86_64\ncompiler info: gnuc: 10.3\nlibc info: glibc: 2.32\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\ncommit-msg\npost-checkout\npost-commit\npost-merge\npre-commit\npre-push\nprepare-commit-msg\n\n\n- Will Beason\n"},{"id":"443177","messageId":"CAPig+cQr27ra4DTjC1gyZO7YdV81Jq5J3s-LcAf+wePP=+n59g@mail.gmail.com","threadId":"57039","inReplyTo":"CAO6o7kKXZg37ydC145yf5uZt+tsKdYADnVfinO0sHAN=cHo-FA@mail.gmail.com","subject":"Re: Checkout previous branch command not working on ​2.34.1.400","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-12-06T17:17:32Z","receivedAt":"2021-12-06T17:17:45Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Dec 6, 2021 at 12:04 PM Will Beason <willbeason@google.com> wrote:\n> I typed \"git checkout -\"\n> error: pathspec '-' did not match any file(s) known to git\n>\n> I expected the previously-working behavior of switching to previous branch to\n> work, but it didn't.\n\nIf I recall correctly, for `-` to work it consults the reflog, but if\nthe reflog has been cleared or expired, it won't be able to determine\nthe previous branch. For instance, try this:\n\n    % git init foo\n    % cd foo\n    % echo data >data\n    % git add data\n    % git commit -m data\n    % git checkout -b other\n    % git checkout -\n    % git reflog expire --expire=now --all\n    % git checkout -\n    error: pathspec '-' did not match any file(s) known to git\n\nSo, this is probably expected behavior, though the error message isn't\nvery helpful and perhaps could be improved.\n"},{"id":"443180","messageId":"CAO6o7k+hphmVKtZtrJEvkZq7TQv8HRCMBSFQ-5JARK2fRoq4sQ@mail.gmail.com","threadId":"57039","inReplyTo":"CAPig+cQr27ra4DTjC1gyZO7YdV81Jq5J3s-LcAf+wePP=+n59g@mail.gmail.com","subject":"Re: Checkout previous branch command not working on ​2.34.1.400","fromName":"Will Beason","fromEmail":"willbeason@google.com","sentAt":"2021-12-06T17:36:58Z","receivedAt":"2021-12-06T17:37:15Z","isPatch":false,"sender":{"key":"willbeason@google.com","avatar":null},"body":"I'm going to bet you're absolutely correct. Yeah, the error message\ncould be clearer.\n\nAfter using \"git checkout [branch]\" for a while, I reflexively typed\n\"git checkout -\" and it worked again.\n\n- Will Beason\n\nOn Mon, Dec 6, 2021 at 11:17 AM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> On Mon, Dec 6, 2021 at 12:04 PM Will Beason <willbeason@google.com> wrote:\n> > I typed \"git checkout -\"\n> > error: pathspec '-' did not match any file(s) known to git\n> >\n> > I expected the previously-working behavior of switching to previous branch to\n> > work, but it didn't.\n>\n> If I recall correctly, for `-` to work it consults the reflog, but if\n> the reflog has been cleared or expired, it won't be able to determine\n> the previous branch. For instance, try this:\n>\n>     % git init foo\n>     % cd foo\n>     % echo data >data\n>     % git add data\n>     % git commit -m data\n>     % git checkout -b other\n>     % git checkout -\n>     % git reflog expire --expire=now --all\n>     % git checkout -\n>     error: pathspec '-' did not match any file(s) known to git\n>\n> So, this is probably expected behavior, though the error message isn't\n> very helpful and perhaps could be improved.\n"}]}