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

Some issues working with empty/bare repositories...

From
RDReece Dunn <msclrhd@googlemail.com>
Date
Mar 1, 2008, 19:40 UTC
Message-ID
<3f4fd2640803011140o38ba0830l7775c8528f812779@mail.gmail.com>
Hi,

Some git operations -- only tried clone and log -- require a repository to contain at least one commit.

    $ git --version
    git version 1.5.3.1

While this is fine when working with existing projects, it can be confusing/problematic when setting up a new repository.

Consider the following workflow:
    $ mkdir foo
    $ cd foo
    $ git --bare init
    $ git log
    fatal: bad default revision 'HEAD'

This message is confusing for a newbie. Displaying "no commits" would make more sense here.

    $ cat HEAD
    ref: refs/heads/master
    $ find refs/heads/master
    find: refs/heads/master: No such file or directory

If the user wants to use the bare repository as the main location of the project, but make changes to it elsewhere (e.g. when setting up a superproject for adding submodules to), they might want to do something like:

    $ git clone foo bar
    Initialized empty Git repository in /home/reece/bar/.git/
    $ ls -a /home/reece
    . .. foo

It appears from the git output (with the inconsistently capitalized git - see --version output above) that the clone succeeded, but it does not create bar/.git/, even though it said that it did.

- Reece
Next: Jeff King
Message 1 of 9 in “Some issues working with empty/bare repositories...”
  1. Reece DunnMar 1, 2008
  2. Jeff KingMar 3, 2008
  3. Reece DunnMar 4, 2008
  4. [RFC] improve 'bad default revision' message for empty repoJeff King, Mar 5, 2008
  5. Junio C HamanoMar 5, 2008
  6. Jeff KingMar 5, 2008
  7. Junio C HamanoMar 5, 2008
  8. Jeff KingMar 5, 2008
  9. Jeff KingMar 5, 2008

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.