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

gitosis: how to create absolutely empty repos

From
LKLasse Kliemann <lasse-gmane-git-2009@mail.plastictree.net>
Date
Feb 25, 2009, 19:54 UTC
Message-ID
<go47ma$5n8$1@ger.gmane.org>

$ mkdir test $ cd test $ git init Initialized empty Git repository in /home/foo/new-repos/test/.git/ $ git remote add origin ext:test.git

('ext' is configured in ~/.ssh/config to be my git user and host.)

Here the docs say to add some files and to do a commit. However, I want an absolutely empty repos created, so I skip this step.

$ git push origin master:refs/heads/master Initialized empty Git repository in /home/git/repositories/test.git/ error: src refspec master does not match any. fatal: The remote end hung up unexpectedly error: failed to push some refs to 'ext:test.git'

So, this did not work. It will work, however, if I do at least one commit. A way to do this without adding files is the following:

$ git commit --allow-empty
Then the push will work:
$ git push origin master:refs/heads/master
Counting objects: 2, done.
Writing objects: 100% (2/2), 168 bytes, done.
Total 2 (delta 0), reused 0 (delta 0)
To ext:test.git
 * [new branch]      master -> master
Is there a better way to do it?
Next: Thomas Rast
Message 1 of 3 in “gitosis: how to create absolutely empty repos”
  1. Lasse KliemannFeb 25, 2009
  2. Thomas RastFeb 26, 2009
  3. Lasse KliemannFeb 26, 2009

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.