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

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


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.


In my case it was the use of "junction tool" (sysinternals). Got that error only when adding new sub directory and files. Using git bash the problem does not occur. Everything else works fine with "junction tool" and TortoiseGit ...