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

git checkout --orphan skips reflogging

From
Dmitry Ivankov <divanorama@gmail.com>
Date
Sep 13, 2011, 18:28 UTC
Message-ID
<CA+gfSn-tVgj=FYiVGK7kmH4gpnXF3HUbs+f=DfRey6GrpadVYg@mail.gmail.com>

In short, git checkout --orphan doesn't write HEAD_sha1 -> 00000 entry to logs/HEAD, while git-comit will write 00000 -> new_orphan_HEAD_sha1 entry. And then reflog backward walk will stop on 000 -> entry and won't see earlier history.

How to reproduce: $ git init test && cd test $ git commit -m A --allow-empty $ git checkout --orphan topic $ git commit -m B --allow-empty $ git log -g --oneline HEAD some_sha1 HEAD@{0}: commit (initial): B # oops, where are my old HEADs? $ cat .git/logs/HEAD 000.. another_sha1 ... commit (initial): A 000.. some_sha1 ... commit (initial): B # phew, at least I can find them by hand

Isn't it also a bug in reflog walking that we rely on each old_sha1 being new_sha1 of a previous entry?

Next: Junio C Hamano
Message 1 of 3 in “git checkout --orphan skips reflogging”
  1. Dmitry IvankovSep 13, 2011
  2. Junio C HamanoSep 13, 2011
  3. Dmitry IvankovSep 14, 2011

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.