git Index corruption

亡梦爱人 提交于 2019-12-07 17:18:33

问题


For some reason my Git index file keeps on getting corrupted.

For example if I do git status I get

error: bad index file sha1 signature and fatal: index file corrupt

This has happened to me several times now. I am thinking perhaps it's something to do with my dev environment. I work on a Mac and have a VMWare Virtual Machine running Debian with Apache MySQL, PHP and Git. I use Samba to connect to the vm to edit my files in my IDE. So I am thinking it has something to do with samba? Is there a better why to connect/share the work space?

The thing is I don't know how to even recreate the problem, I tried varies things to open and close edit and close, restart and what not still no luck.

But then for no reason I am aware of suddenly I get the error again. My work around at the moment is to delete the index file .git/index and do a git reset.

Anyone have any ideas?


回答1:


Your workaround is a good one (recommended at "“Index file corrupt”").

But if samba is problematic, it would be best to get two repos:

  • one on the Mac, where you can:
    • locally edit your files
    • setup a Git server (got daemon, ssh, https, ...)
  • one on the VM, where you can pull from the Mac repo and update your working repo there (on the VM) in order to run your PHP site.



回答2:


You should check this though :) do a little git reset --keep. The one @VonC recommended for!



来源:https://stackoverflow.com/questions/13115956/git-index-corruption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!