Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TortoiseGit Error - Could not get all refs. libgit2 returned: corrupted loose reference file

I just got an error after a recent commit using Tortoise Git:

"Could not get all refs. libgit2 returned: corrupted loose reference file"

which pops up when I go to check the Log.

Any ideas on how to rectify this?

like image 491
John Mattucci Avatar asked Jun 25 '13 18:06

John Mattucci


1 Answers

Your refs are stored inside the raw repository (in .git) in directories (named for each branch) under the "refs" directory. The problem is that one of these files has been corrupted. If you check the code here you'll see that the problem is either that the ref file is less than 40 bytes long, or has a 41st byte that is not a space (or tab, newline, etc). Search through the files in the .git/refs directory and you'll find the bad one. It should contain the 40-character hash of the commit which that branch refers to. You can safely fix it using Notepad.

like image 93
cliffordheath Avatar answered Oct 21 '22 16:10

cliffordheath