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

Re: checkout to a reflog entry

From
Jeff King <peff@peff.net>
Date
Aug 25, 2009, 05:22 UTC
Message-ID
<20090825052200.GA15880@coredump.intra.peff.net>
In-Reply-To
<20090825045235.GB391@debian.b2j>
On Tue, Aug 25, 2009 at 12:52:35PM +0800, bill lam wrote:
Show 8 quoted lines
> project(master)$ git checkout master@{1}
> Note: moving to 'master@{1}' which isn't a local branch
> [...]
> It becomes (no branch) although the SHA1 is correct. If I then
> checkout master, then it revert and jump back up the previous master
> HEAD.  I tried HEAD@{xx} also failed.  What is the correct way of to
> checkout that master@{..} and stay in that master branch?  (Sometimes
> it worked I forgot how and why)

A reflog entry is not a branch; it is just a pointer to the commit where a branch was at some point. Using "git checkout" on it will let you explore the contents, just as you might with a tag. If you want to build on it, you need to either:

  1. Make a new branch to work on, starting at that point:
       git checkout -b my-topic master@{1}
  2. Reset your current branch (and worktree) to point at that commit:
       git reset --hard master@{1}
-Peff
Previous: bill lamNext: bill lam
Message 2 of 3 in “checkout to a reflog entry”
  1. bill lamAug 25, 2009
  2. Jeff KingAug 25, 2009
  3. bill lamAug 25, 2009

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.