GIT:提交时“致命:无法写入 new_index 文件”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3715031/
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: "fatal: unable to write new_index file" while commit
提问by Stepan Kuzmin
When I try to commit changes to local repo, I have got following message:
fatal: unable to write new_index file
当我尝试向本地存储库提交更改时,我收到以下消息:
致命:无法写入 new_index 文件
回答by VonC
As this thread illustrates, this is usually a disk space issue:
正如该线程所示,这通常是磁盘空间问题:
$ git status
fatal: unable to write new_index file
One cause of this that I found was that my file system had run out of space.
Finding large directories with something like the following helped clean up some log files that had run wild :
我发现的一个原因是我的文件系统空间不足。
查找包含以下内容的大目录有助于清理一些运行异常的日志文件:
$ du -h / | grep ^[0-9.]*G
Note: you can also see it for
注意:你也可以看到它
- a resource issuewith msysgit and Egit (Git for Eclipse):
- msysgit 和 Egit(Eclipse 的 Git)的资源问题:
Problem still remained so I ran File Monitor from Sysinternals Suite.
It seems that Eclipse is accessing index file constantly and blocks command line git
问题仍然存在,所以我从 Sysinternals Suite 运行了 File Monitor。
似乎Eclipse正在不断访问索引文件并阻止命令行git
- for a classic anti-virus issue:
- 对于经典的防病毒问题:
Yeah, looks like Windows Defender strikes again. I always forget to disable that damn thing. I can't believe how broken it is. Destroys Blu-ray playback at home, breaks Git at work...
是的,看起来 Windows Defender 又来了。我总是忘记禁用那个该死的东西。我无法相信它有多破碎。在家里破坏蓝光播放,在工作中破坏 Git...
回答by Justin M. Keyes
If you are using TortoiseGit, this error (or more recently: error: Unable to write index.) is very likely caused by having TortoiseGit icon overlaysenabled. To disable icon overlays, go to:
如果您正在使用 TortoiseGit,则此错误(或最近出现的错误:错误:无法写入索引。)很可能是由于启用了TortoiseGit 图标覆盖引起的。要禁用图标覆盖,请转到:
TortoiseGit > Settings > Icon Overlays
TortoiseGit > 设置 > 图标叠加
and set Status cacheto None. This may be fixed in a future version of TortoiseGit, but for now it seems to be common.
并将状态缓存设置为None。这可能会在 TortoiseGit 的未来版本中修复,但目前它似乎很常见。
回答by Phluks
I was getting the same error while I was merging a git repo that was sshfs mounted. There was no shortage of space anywhere.
我在合并安装了 sshfs 的 git 存储库时遇到了同样的错误。任何地方都不缺空间。
In my case the solution was to add an -o workaround=rename option to the sshfs mount command.
在我的情况下,解决方案是向 sshfs mount 命令添加 -o workaround=rename 选项。
Like so: sshfs -o idmap=user -o uid=[lokal uid] -o gid=[lokal gid] -o workaround=rename [host]: [mountpoint]
像这样:sshfs -o idmap=user -o uid=[lokal uid] -o gid=[lokal gid] -o workaround=rename [host]: [mountpoint]
回答by Stepan Kuzmin
I have found solution. Just need to free some disk space.
我找到了解决方案。只需要释放一些磁盘空间。
回答by skybert
I got this error using Cygwin and git-svn. The solution that worked for me was to do garbage collection (odd as it seemed at the time):
我在使用 Cygwin 和 git-svn 时遇到了这个错误。对我有用的解决方案是进行垃圾收集(当时看起来很奇怪):
$ git gc
回答by wpfwannabe
I have followed every solution here and none of them worked. I have no shortage of disk space, I have disabled Windows Defender, disabled icon overlays and whatnot. I had tons of files to import and maybe this was causing the problem (I had boost
libraries among other things).
我遵循了这里的每个解决方案,但没有一个奏效。我不缺磁盘空间,我禁用了 Windows Defender,禁用了图标覆盖等等。我有大量文件要导入,也许这就是问题所在(我有boost
库等)。
I simply opened "Git Bash" and issued a number of git add
and a git commit
and all went well. This has something to do with TortoiseGit but I am not sure what. It seems to choke on a large number of files or large directory depth.
我只是打开了“Git Bash”并发出了一些git add
和一个git commit
,一切顺利。这与 TortoiseGit 有关,但我不确定是什么。它似乎因大量文件或大目录深度而窒息。
回答by philomath
I had same problem. In my case above solutions didn't work.
我有同样的问题。在我的情况下,上述解决方案不起作用。
The reason behind this error is that the file .git/index
was corrupted for some unknown reason. I just renamed the file to something else and run the 'git add .' command from git bash and it worked.
此错误背后的原因是文件.git/index
因某种未知原因而损坏。我只是将文件重命名为其他文件并运行“git add”。来自 git bash 的命令并且它起作用了。
Hope this helps someone.
希望这可以帮助某人。
回答by Cossens
For me it was a file locking issue.
对我来说,这是一个文件锁定问题。
To solve it I:
为了解决它,我:
- Copied the index file (located in the hidden ".git" folder)
- Deleted the original
- Renamed the copy back to 'index'
- 复制索引文件(位于隐藏的“.git”文件夹中)
- 删了原文
- 将副本重命名为“索引”
Hope this helps!
希望这可以帮助!
回答by Duane McKinney
I was having this issue, but I was able to commit with msysgit. I updated tortoisegit, and also noticed that my msysgit version was not in sync with tortoise git. I'm not sure if the latest version fixed it, or if it was due to having different versions of tortoise and msysgit. Anyway, another thing to check. It all started working after updating them both to TortoiseGit 1.7.10.0 git version 1.7.10.msysgit.1
我遇到了这个问题,但我能够使用 msysgit 提交。我更新了 tortoisegit,也注意到我的 msysgit 版本与 tortoise git 不同步。我不确定最新版本是否修复了它,或者是由于 tortoise 和 msysgit 的版本不同。无论如何,另一件事要检查。将它们都更新到 TortoiseGit 1.7.10.0 git 版本 1.7.10.msysgit.1 后,一切都开始工作