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

Possible to make a totally empty repository for remote access?

From
Wincent Colaiuta <win@wincent.com>
Date
Jul 13, 2007, 21:41 UTC
Message-ID
<54C69B03-C589-480E-80D3-75166DBF2D29@wincent.com>

For a new project (no code yet) I wanted to make an empty, bare repository (no working copy) on a remote public server as a starting point, clone it locally, and gradually create content locally and push it out to the remote, public server.

But so far I've been unable to do so in a straightfoward fashion...

mkdir test.git cd test.git git --bare init touch git-daemon-export-ok

If I try to clone such an empty repository I get:
fatal: no matching remote head
And GIT_DIR/HEAD points to refs/heads/master, which doesn't exist yet.
Same if I go for a non-bare, but still empty repository:

mkdir test cd test git init touch .git/git-daemon-export-ok

Only after adding actual content can I clone without getting the "no matching remote head" error:

echo "foo" > bar git add bar git commit -m "foobar"

Then cloning works.

I understand that Git is a *content* manager and a totally empty repository has no content, and therefore no tree object which the HEAD can point to. But the trouble with adding content the way I describe above, is that my public repository is no longer bare; it now has a working copy, which I didn't really want.

What's the way around this? Do I start with a non-bare repository, add any old bogus content, and then convert it to bare and blow away the working copy?

mkdir test cd test git init touch .git/git-daemon-export-ok touch .gitignore git add .gitignore git commit -m "Initial empty repository containing only an empty .gitignore file" git config core.bare true mv .git ../test.git cd .. rm -r test

Is there a better way? Am I missing something obvious?

Cheers, Wincent

Next: Junio C Hamano
Message 1 of 6 in “Possible to make a totally empty repository for remote access?”
  1. Wincent ColaiutaJul 13, 2007
  2. Junio C HamanoJul 13, 2007
  3. Wincent ColaiutaJul 14, 2007
  4. Jeff KingJul 14, 2007
  5. Jeff KingJul 14, 2007
  6. martin f krafftJul 14, 2007

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.