git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug: git checkout @{u} breaks git branch if the upstream isn't a local branch

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 22, 2019, 05:02 UTC
Message-ID
<xmqq7ecrqz65.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAGRskv__Qe-F-grBtq5v-uhHE+BQAcAcOQtX-GKB+MNOrxs0hQ@mail.gmail.com>
Leszek Swirski <leszeks@google.com> writes:
Show 5 quoted lines
> I assume that either the reflog entry should be amended to print
> something more informative (moving from master to origin/master, or at
> least master@{u}, or the SHA...), or the reflog search in
> wt_status_get_detached_from should do something cleverer with relative
> refs.

Nicely analyzed. A record "moving to @{u}" in the reflog may not leave sufficient information for a later operation to tell what branch was refered to with the @{u} reference back when "checkout" was run. I suspect that checking out @{4}, @{1.day.ago}, etc. may share the same issue.

"git checkout @{-1}" aka "git checkout -" may not have any problem after such a checkout, as it only uses "moving from" side of the reflog entry.

Previous: Leszek Swirski
Message 2 of 2 in “Bug: git checkout @{u} breaks git branch if the upstream isn't a local branch”
  1. Leszek SwirskiMar 21, 2019
  2. Junio C HamanoMar 22, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.