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访问权限的。
13 个解决方案
#1
60
I just ran into the same situation, it turned out that my filesystem was full.
我刚刚遇到了同样的情况,原来我的文件系统已经满了。
#2
4
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)
- 将当前工作副本中的所有wc文件复制到克隆文件中(不要复制.git)
- try to commit something in the clone.
- 尝试在克隆中提交一些东西。
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.
当最后一步工作时,需要设置从当前repo到克隆的远程分支,然后可以使用克隆的repo作为新的工作副本。
#3
3
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,所以我在我的Ubuntu运行Parallels上安装了DropBox)
#4
2
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网络驱动器的配置文件设置中填写chekcbox“在移动之前删除现有目标”。
#5
2
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文件夹并删除索引来解决这个问题。锁/索引文件。我不得不重新索引整个应用程序,但它解决了问题。
#6
1
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
#7
1
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.
希望它能帮助别人。
#8
1
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.
我有同样的问题。我仍然不知道原因,但我的解决办法是删除索引。锁定sudo rm -f指数。然后我给sudo chmod 777索引写权限。在这之后,我就可以登台演出了。问题是,我几乎每次都得这么做,我有东西要展示。
#9
1
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的同步。
#10
0
I had a similar problem. "git reset --hard" worked for me.
我也有类似的问题。“git reset——hard”对应于我。
#11
0
To add: surprisingly, some git plug-ins blocks index file. My Eclipse Kepler has default plug-in, that occasionally updates some own info from git repo, blocking index file during that operation.
添加:令人惊讶的是,有些git插件会阻塞索引文件。我的Eclipse Kepler有默认插件,它偶尔更新git repo的一些信息,在操作期间阻塞索引文件。
#12
0
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
#13
0
I had the same error because Google Drive's Backup and Sync client for Windows had not released a lock on two files within this repository. A work around was, after the sync client had finished its work: Process Explorer -> Find -> Find handle or DLL -> Close Handle.
我也犯了同样的错误,因为谷歌驱动器的Windows备份和同步客户端没有对这个存储库中的两个文件释放锁。在同步客户端完成它的工作之后,一个工作是:进程浏览器->查找->查找句柄或DLL ->关闭句柄。
#1
60
I just ran into the same situation, it turned out that my filesystem was full.
我刚刚遇到了同样的情况,原来我的文件系统已经满了。
#2
4
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)
- 将当前工作副本中的所有wc文件复制到克隆文件中(不要复制.git)
- try to commit something in the clone.
- 尝试在克隆中提交一些东西。
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.
当最后一步工作时,需要设置从当前repo到克隆的远程分支,然后可以使用克隆的repo作为新的工作副本。
#3
3
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,所以我在我的Ubuntu运行Parallels上安装了DropBox)
#4
2
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网络驱动器的配置文件设置中填写chekcbox“在移动之前删除现有目标”。
#5
2
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文件夹并删除索引来解决这个问题。锁/索引文件。我不得不重新索引整个应用程序,但它解决了问题。
#6
1
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
#7
1
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.
希望它能帮助别人。
#8
1
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.
我有同样的问题。我仍然不知道原因,但我的解决办法是删除索引。锁定sudo rm -f指数。然后我给sudo chmod 777索引写权限。在这之后,我就可以登台演出了。问题是,我几乎每次都得这么做,我有东西要展示。
#9
1
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的同步。
#10
0
I had a similar problem. "git reset --hard" worked for me.
我也有类似的问题。“git reset——hard”对应于我。
#11
0
To add: surprisingly, some git plug-ins blocks index file. My Eclipse Kepler has default plug-in, that occasionally updates some own info from git repo, blocking index file during that operation.
添加:令人惊讶的是,有些git插件会阻塞索引文件。我的Eclipse Kepler有默认插件,它偶尔更新git repo的一些信息,在操作期间阻塞索引文件。
#12
0
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
#13
0
I had the same error because Google Drive's Backup and Sync client for Windows had not released a lock on two files within this repository. A work around was, after the sync client had finished its work: Process Explorer -> Find -> Find handle or DLL -> Close Handle.
我也犯了同样的错误,因为谷歌驱动器的Windows备份和同步客户端没有对这个存储库中的两个文件释放锁。在同步客户端完成它的工作之后,一个工作是:进程浏览器->查找->查找句柄或DLL ->关闭句柄。