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

Confusing error message due to Git trusting is_bare_repository()

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 25, 2011, 10:56 UTC
Message-ID
<AANLkTi=9CpMU9aZs2zuvRyv3rpECkRAvYA0Srnc61whg@mail.gmail.com>
I had a co-worker git this well-known error message:
    error: refusing to update checked out branch: refs/heads/master
    error: By default, updating the current branch in a non-bare repository
    error: is denied, because it will make the index and work tree inconsistent
    error: with what you pushed, and will require 'git reset --hard' to match
    error: the work tree to HEAD.

It *was* a bare repo, but the config file had bare=false because someone had simply copied a .git tree from a non-bare repo to make it.

The issue is that we just use this:
    int is_bare_repository(void)
    {
        /* if core.bare is not 'false', let's see if there is a work tree */
        return is_bare_repository_cfg && !get_git_work_tree();
    }

For the purposes of the error message it would be helpful if we also detected whether something didn't have a working tree, but was set to bare=false, and tell the user to updatet he bare=false to bare=true for his almost-bare repository.

Next: Junio C Hamano
Message 1 of 3 in “Confusing error message due to Git trusting is_bare_repository()”
  1. Ævar Arnfjörð BjarmasonMar 25, 2011
  2. Junio C HamanoMar 25, 2011
  3. Jeff KingMar 25, 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.