How to handle git gc fatal: bad object refs/remotes/origin/HEAD error?

error: failed to run repack
warning: symbolic ref is dangling: refs/remotes/origin/head
error in git rev-list --stdin objects not remotes/origin exit status 128 fatal: bad object
error: not a valid ref: refs/remotes/origin/master
git fatal bad object refs stash
error: refs/remotes/origin/head: invalid sha1 pointer 0000000000000000000000000000000000000000
git missing object for refs
fatal: unable to parse object: refs/heads/

I randomly hit this today while trying to run Git garbage collect:

$ git gc
fatal: bad object refs/remotes/origin/HEAD
error: failed to run repack

How do I deal with this?

I don't understand the ramifications of this, but as suggested in this thread, when I encountered this I just did

$ mv .git/refs/remotes/origin/HEAD /tmp

(keeping it around just in case) and then

$ git gc

worked without complaining; I haven't run into any problems.

How to handle git gc fatal: bad object refs/remotes/origin/HEAD error, I randomly hit list today while trying to garbage collect. $ git gc fatal: bad object refs/remotes/origin/HEAD error: failed to run repack. How do I deal with this? pack-objects: do not get distracted by broken symrefs. It is quite possible for, say, a remote HEAD to become broken, e.g. when the default branch was renamed. We should still be able to pack our objects when such a thing happens; simply ignore broken symrefs (because they cannot matter for the packing process anyway).

The problem that I ran into (which is the same problem that @Stavarengo mentioned in this comment above) is that the default remote branch (develop in my case) had been deleted, but was still referenced in .git/refs/remotes/origin/HEAD.

Opening .git/refs/remotes/origin/HEAD in my editor showed this:

ref: refs/remotes/origin/develop

I carefully edited it to point at my new default branch and all was well:

ref: refs/remotes/origin/master

The clue that tipped me off was that running git prune showed this error:

> git prune
warning: symbolic ref is dangling: refs/remotes/origin/HEAD

Fixing a git repo - Chris's deck, fatal: bad object refs/remotes/origin/HEAD error: failed to run repack. This may happen if upstream branches have been removed and your origin is pointing to it. Today, while i executed git gc, i got a problem: fatal: bad object refs/remotes/origin/HEADerror: failed to run repack. Don't worry, i can fix it by run

After seeing Trenton’s answer, I looked at my .git/refs/remotes/origin/HEAD and saw that it was also pointing to an old branch that is now deleted.

But instead of editing the file myself, I tried Ryan’s solution:

git remote set-head origin --auto

It automatically set the file to the new branch, and git gc worked fine after that.

Fix bad object refs/remotes/origin/HEAD while execute git gc, I randomly hit list today while trying to garbage collect. $ git gc fatal: bad object refs/remotes/origin/HEAD error: failed to run repack How do I deal with this? I checked with the other machine, everything worked fine there. @dscho Yes, your MCVE indeed resembles the steps I did.. I wonder, why this came up when switchting from 1.9.x to 2.5.x.

I thought the solution was the following since this seemed to work, but it turns out to not actually solve the problem.

git remote set-head origin --auto

Git gc failed to run repack, Today, while i executed git gc, i got a problem: fatal: bad object refs/remotes/ origin/HEADerror: failed to run repack. Don't worry, i can fix it by run. git symbolic- ref� Your repository is actually also behind master with non-git-lfs changes (these don’t appear in git status for some reason when your working copy is in this state) and You do a git push . The fix, of course, is to git pull and merge your non-git-lfs changes and then push again.

Looks like your symbolic-refs might be broken... Try the replacing it with your default branch like this: For example, my default branch is master

$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
$ git fetch --prune
$ git gc

That should fix it.

When doing a git pull, I get a message saying that my reference is , git gc fatal: bad object refs/remotes/origin/HEAD error: failed to run repack How do I deal with this? Next by Date: [jgit-build] Build failed in Jenkins: jgit #1378� Git stores refs and other Git data on disk under the .git folder, and it looks like the value of whatever origin/master entry Git was tracking is now invalid. This will remove the file to hide it from Git locally. git fetch This tells Git to go and fetch whatever it can find from the remote. git branch --set-upstream-to=origin/master

如何处理git gc致命:错误的对象ref / remotes / origin / HEAD错误?, error: bad ref for .git/logs/refs/remotes/origin/HEAD error: bad ref for fatal: bad object refs/remotes/origin/HEAD fatal: failed to run repack. I didn't Sponsoring the developers can help support them to have enough to be paid to manage it. 3. In general, fixing corrupt objects can be pretty difficult. However, in this case, we're confident that the problem is an aborted transfer, meaning that the object is in a remote repository, so we should be able to safely remove our copy and let git get it from the remote, correctly this time.

User Ryan, 我今天在尝试运行Git 垃圾收集时随机打了这个: $ git gc fatal: bad object refs/ remotes/origin/HEAD error: failed to run repack. 我该如何处理? git git-remote� Git Error: Can not add to .git / logs / refs / remotes / origin / master: Permission denied I am having a strange issue that I can't seem to resolve. Here is what happend: I had some log files in a github repository that I didn't want there.

`git gc` broken?, How to handle git gc fatal: bad object refs/remotes/origin/HEAD error? git git- remote git-fetch git-gc asked May 10 '16 at 17:25. stackoverflow.com. Top Answers. git - heads - run garbage collector bad object refs remotes origin head failed to run repack

Comments
  • It worked for me and I think I got into this problem because I changed the default branch from master to another one called develop. Days before I change it back from develop to master and I deleted the old default branch develop, but in my working directory, the file .git/refs/remotes/origin/HEAD was still pointing to refs/remotes/origin/develop which no longer exists. In this situation removing the file did work.
  • git prune worked for me, a way to delete data that has accumulated in Git but is not being referenced by anything useful.
  • Executing them solved my problem: $ mv .git/refs/remotes/origin/HEAD /tmp $ git gc git prune
  • I suspect the best way would be @WilQu's answer (stackoverflow.com/a/49944297/660339). Can anyone confirm this?
  • removing those file out of .git folder, than git gc worked for me
  • That was my fix as well
  • This was my exact solution. Our team recently changed from using a default branch develop to master as well
  • Yep, this works for me - as I was in the exact same scenario. git remote set-head $REMOTE --auto in my case, $REMOTE is the remote alias, not the default "origin", because I have multiple remotes setup.
  • It looks like this command helped me to get rid of the same trouble. However, after this command, I also used git prune (as was recommended in first command output), so I'm not able to tell exactly what helped me - first, second, or both.
  • git remote set-head origin --auto fixed my refs/remotes/origin/HEAD file without me having to use git prune
  • I encountered this error: error: Multiple remote HEAD branches. Please choose one explicitly, and had to use git remote set-head origin mybranch (while the 'mybranch' branch was checkout out) in order to get the error to go away.
  • Downvoting because is not a complete answer and can be misleading.