On Tue, Nov 1, 2022 at 3:15 AM Jeff King <peff@xxxxxxxx> wrote: > > On Fri, Oct 28, 2022 at 10:46:37PM -0700, Martin von Zweigbergk wrote: > > > I did this: > > git init test > > cd test > > echo a > file > > git add file > > git commit -m a > > git checkout --orphan other > > git branch --delete main > > > > The last command fails with: > > fatal: Couldn't look up commit object for HEAD > > > > That's a bug, right? I can of course work around it with `rm > > .git/refs/heads/main`. > > Sort of. This is part of the "is the thing we are deleting merged into > HEAD" check. It tries to look up the HEAD and calls die() when it can't. > The more correct thing, I think, would be for it to just return "nope, > there is no HEAD so nothing is merged into it". Ah, so that's what it was about. Thanks for looking into it! > And in the meantime, hopefully you noticed that "-f" is a better > workaround than manually deleting the refs file. :) Nope, because I had no idea it was something that could be first. Also, this was just in a script to reproduce an unrelated (non-Git) bug, so my hacky workaround was okay :) Thanks!