# gitosis: how to create absolutely empty repos

3 messages from 2009-02-25 to 2009-02-26. Participants: Lasse Kliemann, Thomas Rast.
Thread: https://gitlist.dev/t/18019

## Lasse Kliemann, 2009-02-25 19:54

Subject: gitosis: how to create absolutely empty repos
Message-ID: <go47ma$5n8$1@ger.gmane.org>
URL: https://gitlist.dev/e/go47ma%245n8%241%40ger.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?

```

## Thomas Rast, 2009-02-26 09:23

Subject: Re: gitosis: how to create absolutely empty repos
Message-ID: <200902261023.46700.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200902261023.46700.trast%40student.ethz.ch
In-Reply-To: <go47ma$5n8$1@ger.gmane.org>

```
Lasse Kliemann wrote:
> 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'

You can do "anything" to the repository and gitosis will create it.
For example, doing an invalid push will work (you'll need to do this
in a git repository to make git-push happy, but it doesn't matter what
it contains):

  git push gitosis@server.example.com:repo.git :master

Note that _cloning_ such a repository is only possible since 86ac751
(Allow cloning an empty repository, 2009-01-23), which is not in any
released version yet, but will be in 1.6.2.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```

## Lasse Kliemann, 2009-02-26 11:54

Subject: Re: gitosis: how to create absolutely empty repos
Message-ID: <go5vtc$3dj$1@ger.gmane.org>
URL: https://gitlist.dev/e/go5vtc%243dj%241%40ger.gmane.org
In-Reply-To: <200902261023.46700.trast@student.ethz.ch>

```
Thomas Rast <trast@student.ethz.ch> writes:

Thank you for your reply!

> You can do "anything" to the repository and gitosis will create it.
> For example, doing an invalid push will work (you'll need to do this
> in a git repository to make git-push happy, but it doesn't matter what
> it contains):
> 
>  git push gitosis@server.example.com:repo.git :master
> 
> Note that _cloning_ such a repository is only possible since 86ac751
> (Allow cloning an empty repository, 2009-01-23), which is not in any
> released version yet, but will be in 1.6.2.

Not sure if it's the same, but cloning a local repository just initialized 
with 'git init' seems to work; it only gives a warning: "warning: remote HEAD 
refers to nonexistent ref, unable to checkout." Using git version 1.6.1.3.

```
