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

后端 未结 8 1459
庸人自扰
庸人自扰 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条回答
  •  面向向阳花
    2021-01-30 03:29

    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.

提交回复
热议问题