4

I'm getting the following error in GitX-L when opening a git repository:

The document “REPO_NAME” could not be opened.

An error occured while trying to open file://localhost/Volumes/SERVER/www/REPO_NAME/.git/.
fatal: missing object 0000000000000000000000000000000000000000 for refs/remotes/origin/HEAD

Does anyone know what is causing this issue or how to fix it? I don't get the error while using the command line, so I'm assuming it is a problem with GitX-L.

git fsck does tell me about a bunch of dangling entries, could those be to blame?

Thomas Hunter II
  • 5,081
  • 7
  • 35
  • 54
  • Check that HEAD points to something - it may be empty. You appear to have a null sha1, and it says you are trying to open the file `.` which is simply the current directory. – Philip Oakley May 15 '12 at 15:46

3 Answers3

8

I had the same error message when opening a repository in 'GitX' (a GUI tool).

For me, the problem was caused by the file .git/refs/remotes/origin/HEAD, which referenced a remote branch which I had deleted:

ref: refs/remotes/origin/develop

I fixed it by editing the file to contain the name name of a remote branch which did still exist:

ref: refs/remotes/origin/master
Jonathan Hartley
  • 15,462
  • 9
  • 79
  • 80
3

It looks like something is wrong with the origin remote ref... Remove the culprit from Terminal with git branch -r -d origin/HEAD, or even git remote prune origin and re-open it in GitX.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • Didn't work for me: "error: remote branch 'origin/HEAD' not found." This sounds bad, but I don't understand what it really means. Recloning the remote repo fixed the problem for me. – Jonathan Hartley Dec 12 '12 at 11:12
  • `git branch -r -d origin/HEAD` worked for me. @Jonathan Hartley - I'm pretty sure that it isn't a bad thing. It means that you don't have a local representation of the remote branch on `origin` named `HEAD`. At any rate, recloning the remote repo, if that is an option, is always a safe bet. – Grant Hutchins Dec 01 '13 at 00:29
1

I had the same problem.

A simple solution is to clone the faulty repository and start using the clone instead. It worked for me.

Olivier Verdier
  • 46,998
  • 29
  • 98
  • 90