git clone is the command you use to clone and start working with a remote repository. Only problem is, this command does not work if the remote repository is empty. Instead it responds with this cryptic error message:
$ git clone ssh://git.fedorahosted.org/git/autobuildrequires.git Initialized empty Git repository in autobuildrequires/.git/ fatal: no matching remote head
I sent a rant about this to the git developers last month. The response was basically that I’m stupid and should have read the manual page to
git-push. Let’s do that now:
git-push – Update remote refs along with associated objects
Updates remote refs using local refs, while sending objects necessary to complete the given refs.
You can make interesting things happen to a repository every time you push into it, by setting up hooks there. See documentation for git-receive-pack(1).
Do I think it’ll be worth my time following the link to
Here’s how to solve the problem
I don’t pretend to understand git, but I think that a git repository doesn’t exist unless it has at least one commit. Firstly we need to create a repository on the local machine and add a commit to it:
mkdir autobuildrequires cd autobuildrequires git init touch README git add README git commit -a -m "First commit."
Now we have a repository containing one commit. You can check this with the
git log command.
Next we have to tell git that the
origin of the local repository is the remote repository. The origin is where git checks by default when you do a
git pull. So do this, obviously replacing the URL with the correct URL for your repository:
git remote add origin ssh://git.fedorahosted.org/git/autobuildrequires.git
Now the final, confusing step. We have to connect the upstream
origin with the current local branch (usually called
master). This involves editing a config file:
and adding the following at the bottom:
master remote = origin merge = refs/heads/master
(You should see the
[remote "origin"] section in the config file already, which is what the previous
git remote add origin command did).
We’re not quite over yet. For reasons completely unknown, you now have to do:
git push origin master
and that should make your commit appear remotely. At this point, plain
git pull and
git push should work as expected.
What a palaver!