Pete On Software

RSS Feed

Git Error : (does not point to a valid object)

A friend of mine IMed me the other day to ask if I had ever seen an error like the one below:

I had not, but it seemed plain enough. It appeared that the head of the master branch was pointing to a commit that didn’t actually exist in the repository. I don’t know for sure how this happened, but my friend’s team suspected a disrupted internet connection on push as one theory.

I Googled the error and found suggestions like “make a new remote” and “clone to a new branch, push, delete master, rename new branch”. This seemed like just too much work. There had to be an easier solution.

I was unable to clone the remote to my own machine (I got that same error on trying) and the team was in another state, so – short of a screensharing session – I couldn’t easily work with them on the problem.

I had the developer who had done the last known valid commit before this error send me the most recent 5 items output from the “git log” command and got the following (edited for privacy):

Because Git is based in the file system, I could literally navigate to the remote file system and go to the ProjectName.git folder and into the refs/heads/ folder and find the master file (no extension). Inside was one string, the offending e291a84831b445ba982539cc63a418126f0b5364. I just replaced that string with the hash of the latest valid commit – b65f24a64e78b38d193aa545d7b184fe26330a4c – and then saved.

After that, I could clone the repo and the developers could pull, merge, and push their own changes. They were using DropBox in this instance as a “poor man’s remote” and upon further reflection, I have to wonder if that is what caused the conflict. Perhaps there was a problem with DropBox syncing all of the files and maybe a race condition at some point that resulted in a corruption? I know DropBox isn’t a perfect “remote server” solution, but a lot of people use it for certain circumstances, so this might be something to look out for.

If anyone else has seen this error and has a better fix than the one described here, then please leave a comment and let me know.


mgroves  on July 30th, 2012

I use Dropbox as a personal private repo, but for multiple developers it seems like you’d be asking for trouble. Dropbox has its own conflict management (it’s essentially a file-based version control system unto itself). After pushing to your Dropbox origin, there’s a window of time while those updates get pushed to Dropbox and updated on other team member’s computers. If another push happens during that window, there could be some nasty problems.

If you’re more than a team of 1, you’re better off with a private git repo like github (there are some free ones too).

developingchris  on July 30th, 2012

I have had this problem when using a synced drive as a backing store for remotes. In my experience, the fix is the same and problem is a race condition. As soon as I found this out, I also heard about’s support for git. It’s 1$/collaborator/month, unlimited disk and repos. It’s not github, but it’s so cheap, that I’ve moved all my private stuff there.

Pete  on July 30th, 2012

Matt and Chris, glad I’m not crazy and there seems to be some consensus here, thanks for the comments. And Chris, I’ll have to personally check out BitBucket’s plans. They aren’t Github, but they HAVE to be better than DropBox!

Leave a Comment