1

My morning started with git pull, just like any other morning:

$ git pull
error: unable to resolve reference refs/remotes/origin/card-declined: Undefined error: 0
From github.com:instaedu/instaedu
 ! [new branch]      card-declined -> origin/card-declined  (unable to update local ref)

(FYI, "card-declined" is a branch I pushed to GitHub just last night, and hasn't had any activity since then.)

I've never seen that error before, so I looked it up and found this question: git pull fails “unalble to resolve reference” “unable to update local ref”. The top-voted answer there says to try running git gc --prune=now, so I did that:

$ git gc --prune=now
error: bad ref for refs/remotes/origin/card-declined
error: bad ref for refs/remotes/origin/card-declined
fatal: loose object b28488de1ef3f6887eef99c0316a654d1803e6af (stored in .git/objects/b2/8488de1ef3f6887eef99c0316a654d1803e6af) is corrupt
error: failed to run repack

It didn't seem to fix anything, though now I see that something seems to have been corrupted since yesterday.

Any idea how to resolve this?

Community
  • 1
  • 1
Riley Watkins
  • 3,453
  • 3
  • 25
  • 19
  • perhaps a fresh `git clone`? it looks like your repo is corrupt... – nneonneo Sep 26 '12 at 17:15
  • @nneonneo That may be what I end up doing, but I'm still curious to see if it can be fixed first. – Riley Watkins Sep 26 '12 at 17:23
  • possible duplicate of [git pull fails "unable to resolve reference" "unable to update local ref"](http://stackoverflow.com/questions/2998832/git-pull-fails-unable-to-resolve-reference-unable-to-update-local-ref) – Lucio Aug 13 '14 at 14:19

2 Answers2

3

Although I re-cloned the repository so I could continue working, I did keep the old corrupted one around, in case I happened to find a way to fix it. Unfortunately, I found no such fix.

If you run into this problem, your best bet is just to git clone the repository again. Hopefully you've already pushed your latest changes to a remote before the repo got corrupted.

Riley Watkins
  • 3,453
  • 3
  • 25
  • 19
0

I solved the issue by deleting the bad refs, e.g.:

del .git\refs\remotes\origin\card-declined
del .git\refs\remotes\origin\card-declined

It was mostly a hunch, but it seems to have worked because I did not care about the troublesome refs.

kiewic
  • 15,852
  • 13
  • 78
  • 101