Reputation: 3679
I recently upgraded my Ubuntu local server to 14.04. I don't know if it's related with upgrade or not, but things is there was no such problem before. The problem is,
Googled this problem, and found that, deleting this file will fix problem. Removed index.lock file. Got error:
error: bad signature
fatal: index file corrupt
Tried to git reset
. After reset, tried to add, commit and push. First try gone well. It pushed commit without any problem. But second try, again same problem.
Tried to remove repo and clone again. Tried to chown -R root:root /var/www
, to chmod -R 777 .git/
of project. I even reinstalled OS ubuntu 14.04 server. Now same error message again.
Any suggestions? What to do next?
Upvotes: 1
Views: 3657
Reputation: 3454
The curious thing about your problem is that your git repo is in a public-ish place /var/www in the sense that perhaps you've got other services enabled (eg. web served filesystem) that allow update of files in /var/www. What I suggest is cloning the repo into something like /home/heron/private/git0 and then see if it behaves itself there.
Another thing you could do is create a filesystem originating from an filesystem file, mount it up and then try git. This is interesting because it forces you to check over the filesystem options.
For example, I had weird issues with checking out the linux repo once, and this approach helped me figure out the problem (for linux, you need a case-sensitive filesystem mounted as files in linux kernel can be different by case alone). Your issue may be different in character, but the experimental method shown here may be still valid.
Upvotes: 1
Reputation: 1245
In your repository run the following commands:
rm -rf .git/index
git reset --hard HEAD
Upvotes: 2
Reputation: 119
Try deleting the index file itself and then reset, like this:
$ cd <your repo>
$ rm .git/index
$ git reset
this should rebuilt your index.
Upvotes: 4
Reputation: 4496
Check what process is running that locks the file:
sudo lsof /var/www/XXXXXXXXXXX/.git/index.lock
If no process is using the file, consider restarting the system, if that doesn't work remove the file. After that, do a back up of your work and run git reset
. Verify the objects of the repository using git fsck --full
.
Upvotes: 2