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

后端 未结 8 1458
庸人自扰
庸人自扰 2021-01-30 02:36

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
         


        
8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 03:20

    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.

提交回复
热议问题