Possible to make a totally empty repository for remote access?
From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:43:21
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