'Git Pull fatal: Couldn't find remote ref HEAD

GIT newbie here. I am trying my luck with a VPS running on ubuntu 12.04 x 64 to act as a private repository for my development. So I thought I might try my luck with git. I have installed git on the remote server and initialized a git repository which is sitting on the /var/www directory. I mainly develop php apps so I try to set the code to go to www so any commits could be tested then and there instead of moving from the users' folder back in to the www.

I am trying to pull from the remote repo. I am using GIT extensions to handle my GIT requirements on my windows computer.

However, when I try to pull data from the remote repository I get the below error.

C:\msysgit\cmd\git.exe pull --progress "Horizon" :refs/remotes/Horizon/master
fatal: Couldn't find remote ref HEAD
fatal: The remote end hung up unexpectedly
Done

any idea on what I have done wrong?

git


Solution 1:[1]

You want git pull Horizon master. The second parameter to git pull is optional and defaults to 'HEAD'. The error is saying that inside the remote called Horizon, there is no HEAD, which is perfectly possible. But it seems from your command that you know the master branch does exist. It is not necessary to use quotes around the remote name, nor is the ':refs/remotes/Horizon/' prefix to the target branch master necessary (although I've checked, it is valid).

If you are new to git, I recommend installing a git GUI such as GitExtensions. There are many to choose from, that's just the one I personally recommend.

Solution 2:[2]

Is Horizon your remote? You can check it with git remote -v, if not, you have to add it to your local repo with git remote add ... . See the docs about git remote function.

How did you create your local repo? With git clone? If you initializaed your local repo in thhe same way as you did with remote (on ubuntu), you need to set fetch and push URLs (set the remote).

After ensuring all above, try pulling with

git pull origin master

where origin is name of your remote, if you set it to horizon, it should be

git pull horizon master

and master is branch you are working on.

I didn't see anywhere specifying branch as you did, you just specify remote name and branch name, the rest is up to git to resolve :) that's the beauty of it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TamaMcGlinn
Solution 2 Michał Turczyn