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

后端 未结 8 1580
庸人自扰
庸人自扰 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:20

    If you're using git worktrees, make sure you're doing a

    git worktree prune
    

    before running

    git gc
    

    I had a worktree get corrupted and this seemed to do the trick after removing the corrupted worktree. git prune by itself didn't seem to work.

提交回复
热议问题