What causes a damaged git index file

I get this message about once per hour:

error: file with bad sha1 index fatal: index file is damaged

I’ve already looked online and I know how to solve it, but I’m trying to find out what causes it.

I use command line tools on the server, but I have a directory installed (via sshfs) on my local computer. But I do not use local git, but only the version on the remote server.

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

Are there any clues as to what might be the problem?

+4
source share
3 answers

i does not use local git, but only the version on the remote server.

There is my bet for your problem right there.

Do your work in your repo. Click on the server repo when you have work in some form suitable for publication. If you want to share your work in progress, see, for example, Git push / pull between local repositories of team members

(edit: you are using sshfs . Do not do this for anything less multi-user. This is the FUSE single-user interface for sftp . Even if you disable its caching, which has not closed the race yet.)

+1
source

If you have not found a way to resolve the Git index file directly, run the following commands that remove the Git index file from the .git directory in your repository and take the current branch and reset to point it elsewhere, and list the index and the work tree before remembering backup .git/index just in case):

 $ rm .git/index $ git reset 
0
source

If you have git installed on the remote server, which also serves as the root for the IntelliJ project, then you will have a lock conflict on git. IntelliJ will constantly mess up your git index, since you can also (for example) use git in your repo on the command line in a terminal session.

The solution is to unregister any version control in IntelliJ software by choosing Settings> Version Control and removing your project from this list. This should indicate that your IDE completely ignores the existence of git in the project root folder and forever ceases to compete for managing the git index.

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

0
source

Source: https://habr.com/ru/post/1499702/


All Articles