0

When i type git reflog in the git bash, it show nothing. And when i select show reflog on the context manu of TortoiseGit, it says

"error while loading reflog. libgit2 returned: unable to parse OID, contains invalid characters".

The other functions of git is good. I have searched solutions of this problem for hours among Google and Bing. But it still can not be figured out. What should i try next to fix the problem or find the reason?

1 Answers1

0

The reflog for HEAD is a plain text file stored at .git/logs/HEAD.

You can check if this file exists, is accessible, and if you see something fishy in its content.


Each line should look like :

<sha1> <sha1> <author + unix timestamp + timezone> <1 line commit message>

From the error message : one of the sha1 part must have been corrupted.


If the error is obvious enough (file truncated, obvious join of two lines ...) you can try to manually edit the file, and remove or fix the faulty lines.

The two sha1 mean "the reference moved from this commit to this commit". So they are "linked" between lines : the second sha1 of line n-1 is the first sha1 of line n, the first sha1 of line n+1 is the second of line n.

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • Amazing! Just as what you said, all the text files at ```.git/logs/``` are corrupted. But whatever location i initialize a new local repository at, and do some commits. All the text files under ```.git/logs/``` generated by git will be corrupted, while other file under ```.git/``` is still normal. There are some invalid characters are always introduced into these files. I have tried reinstall git, but it does not work. How the file at ```.git/logs/``` modified by git? – HandsomeBigEye May 26 '20 at 14:33
  • Can you edit your question, and describe what kind of invalid content you see in your log files ? – LeGEC May 26 '20 at 15:40
  • It looks like ```2?程2爽梦:氚?C1匆J,5誚c嵉鏋sf49c7a18ac146012b644844f84f1c74b1b7f9275 0907b109fb13255c1fb88d3b649d72eae84904f7 RX-Deng 1590503795 +0800 commit: this is another test commit``` BTW, I work with git in the language environment of Chinese. – HandsomeBigEye May 26 '20 at 15:55
  • Hi,i figure out this problem finally after i reinstall the git with version 2.18 in 32 bit while the version that i installed before is 2.26 in 64 bit. It is occured on the computer that is in my company, so that i can not install other version except the two version i mentioned above. Thank you again. – HandsomeBigEye Jun 02 '20 at 16:52