dbers
dbers

Reputation: 654

What causes corrupt git index file

I keep getting this message about once an hour:

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

I've already looked online and know how to resolve it, but trying to figure out whats causing it.

I use command line tools on the server, but have the directory mounted (through sshfs) on my local computer. But i don't use local git, only the version on the remote server.

The only other thing i can think of is IntelliJ, but i stopped using there git commands thinking it was causing the conflict.

Does anyone have any clues as to what the issue could be?

Upvotes: 5

Views: 5434

Answers (3)

Adam Friedman
Adam Friedman

Reputation: 549

If you have git installed on a remote server location that also serves as the root for an IntelliJ project, then you are going to have lock contention on git. IntelliJ will continually corrupt your git index as you may also be (for instance) using git in your repo on the command-line in a terminal session.

The solution is to de-register any version control within the IntelliJ software by going to Settings > Version Control and removing your project from that listing. This should tell your IDE to completely ignore the existence of git in that project root folder, and forever cease competing for control of the git index.

See also this question: How to disable version control in phpstorm?

Upvotes: 2

jthill
jthill

Reputation: 60255

i don't use local git, only the version on the remote server.

There's my bet for your problem right there.

Do your work in your repo. Push to the server repo when you've got your work in some shape fit to publish. If you want to share your work-in-progress see e.g. Git push/pull between team members local repositories

(edit: you're using sshfs. Don't Do That for anything the least bit multi-user. it's a single-user convenience FUSE frontend for sftp. Even if you shut off its caching that still wouldn't close the races.)

Upvotes: 3

user2005477
user2005477

Reputation:

Unless you find a way of resolving the Git index file directly, run the following commands which delete the Git index file from the .git directory in your repository and "take the current branch and reset it to point somewhere else, and bring the index and work tree along" (but before, remember to backup your .git/index just in case):

$ rm .git/index
$ git reset

Upvotes: 1

Related Questions