git 问题:致命:无法写入新的索引文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3813962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git problem : fatal: Unable to write new index file
提问by Dan Donaldson
I have an existing project that has been managed under git. I recently had to do a ground-up rebuild of the computer (OS X Snow Leopard), and returning to the project, git can track the changes in the project, but I can't save anything to git. I get the error in the title when I try :
我有一个在 git 下管理的现有项目。最近不得不对电脑(OS X Snow Leopard)进行彻底的重建,回到项目中,git可以跟踪项目中的变化,但是我无法将任何内容保存到git中。当我尝试时,标题中出现错误:
Dans-iMac-335:[app-name-obscured] apple$ git add app/models/*
fatal: Unable to write new index file
What's the best way to recover from this situation? There is a heroku repository version of this, but it is very out of sync with this one. presumably I could use a new clone as a basis, and update each file, but that seems over laborious and error prone.
从这种情况中恢复的最佳方法是什么?有一个 heroku 存储库版本,但它与这个版本非常不同步。大概我可以使用一个新的克隆作为基础,并更新每个文件,但这似乎过于费力且容易出错。
What is git looking for here that it can't find, and is there a change that will restore it?
git 在这里找不到它在寻找什么,是否有更改可以恢复它?
BTW, file permissions are correct from what I can tell - the files under control and the .git components are both owned by me with rw access...
顺便说一句,据我所知,文件权限是正确的 - 受控制的文件和 .git 组件都归我所有,具有 rw 访问权限......
回答by Timmy
I just ran into the same situation, it turned out that my filesystem was full.
我刚刚遇到了同样的情况,结果我的文件系统已满。
回答by Rudi
Do you have write access to .git (=can you create new files there and edit existing ones)? If not then adjust the file permissions.
你有 .git 的写权限吗(=你可以在那里创建新文件并编辑现有文件)?如果没有,则调整文件权限。
If you have write permissions it seems you found a bug. You can try to recover by
如果您有写权限,您似乎发现了一个错误。您可以尝试通过以下方式恢复
- create a clone from your current working copy
- remove all files from the working copy of the clone
- copy all wc files from your current working copy to the clone (and don't copy .git)
- try to commit something in the clone.
- 从您当前的工作副本创建一个克隆
- 从克隆的工作副本中删除所有文件
- 将当前工作副本中的所有 wc 文件复制到克隆中(不要复制 .git)
- 尝试在克隆中提交一些东西。
When the last step works you need setup the remote branches from your current repo to the clone, and then you can use the cloned repo as your new working copy.
当最后一步工作时,您需要设置从当前存储库到克隆的远程分支,然后您可以将克隆的存储库用作新的工作副本。
回答by Scott Silver
I was using Parallels running Ubuntu on my Mac. I could git init, but not git add. I believe the issue is that git add requires an atomic synch to the underlying git database. And since the filesystem I was using was actually on my Mac and Parallels was exporting from my Mac via a network share. I believe this means that git couldn't do what it wanted. Moving the files locally fixed the problem (In my case this was easy since I was using DropBox on my Mac, so I just installed DropBox on my Ubuntu running Parallels)
我在 Mac 上使用 Parallels 运行 Ubuntu。我可以 git init,但不能 git add。我认为问题在于 git add 需要与底层 git 数据库进行原子同步。由于我使用的文件系统实际上是在我的 Mac 上,Parallels 是通过网络共享从我的 Mac 导出的。我相信这意味着 git 不能做它想做的事。在本地移动文件解决了问题(在我的情况下,这很容易,因为我在 Mac 上使用 DropBox,所以我只是在运行 Parallels 的 Ubuntu 上安装了 DropBox)
回答by Travis Mathis
I was able to fix this by going into the .git folder in the git initiated app and deleting the index.lock/index file. I had to reindex the entire app, but it resolved the problem.
我能够通过进入 git 启动的应用程序中的 .git 文件夹并删除 index.lock/index 文件来解决这个问题。我不得不重新索引整个应用程序,但它解决了问题。
回答by Valera Dubrava
I've had a simular problem with SFTP Network Drive (free). The solution is: fill chekcbox "Delete existing target before moving" found in the Profile Settings of SFTP Network Drive.
我遇到了 SFTP 网络驱动器(免费)的类似问题。解决方法是:在SFTP网络驱动器的配置文件设置中填写勾选框“移动前删除现有目标”。
回答by Kanedias
I'd like to point out one more cause of this error
我想指出这个错误的另一个原因
If you are cloning a git repository that contains another git repository in it (not submodule), you will get this behaviour.
如果您要克隆包含另一个 git 存储库(不是子模块)的 git 存储库,您将获得此行为。
Hope it'll help somebody.
希望它会帮助某人。
回答by Dave Halter
If you are using sshfs
, add the option -o workaround=rename
, as described here: http://alan.lamielle.net/2009/07/08/git-over-sshfs
如果您正在使用sshfs
,请添加选项-o workaround=rename
,如下所述:http: //alan.lamielle.net/2009/07/08/git-over-sshfs
回答by Paulo Borralho Martins
I had same problem. I still dunno the cause, but my workaround is delete index.lock sudo rm -f index.lock
, and then i gave write permission to index sudo chmod 777 index
. After this I am able to stage and commit. The problem is I have to do this almost all the times I have something to stage.
我有同样的问题。我仍然不知道原因,但我的解决方法是删除 index.lock sudo rm -f index.lock
,然后我给了 index 写权限sudo chmod 777 index
。在此之后,我能够上演和提交。问题是我几乎每次都有要上演的东西时都必须这样做。
回答by Omegastick
This is old, but the cause for me was Dropbox. My local repository was stored in my Dropbox folder, and I had to pause Dropbox syncing before I could complete the command.
这是旧的,但对我来说是Dropbox。我的本地存储库存储在我的 Dropbox 文件夹中,我必须在完成命令之前暂停 Dropbox 同步。
回答by No.8
I had used this problem when using git on visual studio, and my solution was to run visual studio as an administrator
我在visual studio上使用git的时候就遇到过这个问题,我的解决办法是以管理员身份运行visual studio