GIT:“致命:无法写入 new_index 文件”提交时

发布于 2024-09-19 02:16:57 字数 61 浏览 10 评论 0原文

当我尝试将更改提交到本地存储库时,我收到以下消息:
致命:无法写入 new_index 文件

When I try to commit changes to local repo, I have got following message:
fatal: unable to write new_index file

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

春风十里 2024-09-26 02:16:57

正如这个线程所示,通常是磁盘空间问题:

$ git status
fatal: unable to write new_index file

我发现造成这种情况的原因之一是我的文件系统空间不足。
查找具有如下内容的大目录有助于清理一些疯狂运行的日志文件:

$ du -h / | grep ^[0-9.]*G

中看到它

问题仍然存在,所以我从 Sysinternals Suite 运行文件监视器。
看来 Eclipse 正在不断访问索引文件并阻止命令行 git

是的,看起来 Windows Defender 又来袭了。我总是忘记禁用那个该死的东西。我简直不敢相信它有多破。破坏了家里的蓝光播放,破坏了工作中的 Git...


在 Git 2.46(2024 年第 3 季度)之前,第 17 批,当“git合并(man) 发现索引无法刷新(例如,由于另一个进程在后台执行相同的操作),它死掉了,但是写入 MERGE_HEAD 等文件之后,这是对于从失败中恢复的目的毫无用处。

请参阅 提交 2e5a636(2024 年 6 月 17 日),作者:凯尔·赵 (yefengzkk)
(由 Junio C Hamano -- gitster -- 合并于 提交 6c0bfce,2024 年 6 月 27 日)

merge:避免在无法写入合并状态时写入索引

签字人:赵凯

在索引写入失败后写入合并状态是没有意义的,并且可能会导致 Git 丢失更改。

这意味着,当您遇到致命错误时,您将不再看到任何错误:

  • .git/MERGE_HEAD
  • .git/MERGE_MODE
  • .git/MERGE_MSG

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

Problem still remained so I ran File Monitor from Sysinternals Suite.
It seems that Eclipse is accessing the index file constantly and blocks command line git

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...


Before Git 2.46 (Q3 2024), batch 17, when "git merge"(man) sees that the index cannot be refreshed (e.g., due to another process doing the same in the background), it died but after writing MERGE_HEAD etc. files, which was useless for the purpose to recover from the failure.

See commit 2e5a636 (17 Jun 2024) by Kyle Zhao (yefengzkk).
(Merged by Junio C Hamano -- gitster -- in commit 6c0bfce, 27 Jun 2024)

merge: avoid write merge state when unable to write index

Signed-off-by: Kyle Zhao

Writing the merge state after the index write fails is meaningless and could potentially cause Git to lose changes.

That means, when you encounter that fatal error, you will no longer see any:

  • .git/MERGE_HEAD
  • .git/MERGE_MODE
  • .git/MERGE_MSG
萌吟 2024-09-26 02:16:57

如果您正在使用 TortoiseGit,此错误(或者最近的错误:错误:无法写入索引。)很可能是由于启用了 TortoiseGit 图标覆盖而导致的。要禁用图标覆盖,请转到:

TortoiseGit >设置>图标叠加

并将状态缓存设置为。这可能会在 TortoiseGit 的未来版本中得到修复,但目前看来很常见。

If you are using TortoiseGit, this error (or more recently: error: Unable to write index.) is very likely caused by having TortoiseGit icon overlays enabled. To disable icon overlays, go to:

TortoiseGit > Settings > Icon Overlays

and set Status cache to None. This may be fixed in a future version of TortoiseGit, but for now it seems to be common.

春夜浅 2024-09-26 02:16:57

当我合并 sshfs 安装的 git 存储库时,我遇到了同样的错误。任何地方都不缺乏空间。

就我而言,解决方案是向 sshfs mount 命令添加 -o workaround=rename 选项。

就像这样:
sshfs -o idmap=用户 -o uid=[lokal uid] -o gid=[lokal gid] -o 解决方法=重命名 [主机]: [挂载点]

I was getting the same error while I was merging a git repo that was sshfs mounted. There was no shortage of space anywhere.

In my case the solution was to add an -o workaround=rename option to the sshfs mount command.

Like so:
sshfs -o idmap=user -o uid=[lokal uid] -o gid=[lokal gid] -o workaround=rename [host]: [mountpoint]

没有伤那来痛 2024-09-26 02:16:57

我有同样的问题。就我而言,上述解决方案不起作用。

此错误背后的原因是文件 .git/index 由于某种未知原因而损坏。我只是将该文件重命名为其他名称并运行“git add”。来自 git bash 的命令并且有效。

希望这对某人有帮助。

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.

Hope this helps someone.

峩卟喜欢 2024-09-26 02:16:57

我已经找到解决方案。只需释放一些磁盘空间即可。

I have found solution. Just need to free some disk space.

甜嗑 2024-09-26 02:16:57

对我来说这是一个文件锁定问题。

为了解决这个问题,我:

  1. 复制了索引文件(位于隐藏的“.git”文件夹中)
  2. 删除了原始文件
  3. 将副本重命名回“index”

希望这有帮助!

For me it was a file locking issue.

To solve it I:

  1. Copied the index file (located in the hidden ".git" folder)
  2. Deleted the original
  3. Renamed the copy back to 'index'

Hope this helps!

安静 2024-09-26 02:16:57

我已经遵循了这里的每个解决方案,但没有一个有效。我不缺少磁盘空间,我禁用了 Windows Defender、禁用了图标覆盖等等。我有大量文件要导入,也许这就是导致问题的原因(除其他外,我还有 boost 库)。

我只是打开“Git Bash”并发出了一些 git addgit commit ,一切都很顺利。这与 TortoiseGit 有关,但我不确定是什么。它似乎因大量文件或大目录深度而窒息。

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).

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.

执笏见 2024-09-26 02:16:57

我使用 Cygwin 和 git-svn 遇到此错误。对我有用的解决方案是进行垃圾收集(当时看起来很奇怪):

$ git gc

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):

$ git gc

残龙傲雪 2024-09-26 02:16:57

我遇到了这个问题,但我能够使用 msysgit 提交。我更新了 tortoisegit,还注意到我的 msysgit 版本与 tortoise git 不同步。我不确定最新版本是否修复了这个问题,或者是否是由于 Tortoise 和 msysgit 版本不同所致。无论如何,还有一件事要检查。将它们更新为后一切都开始工作
乌龟Git 1.7.10.0
git版本1.7.10.msysgit.1

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

叹沉浮 2024-09-26 02:16:57

我在 macOS 上遇到了同样的问题,我通过删除 repo_folder/.git/index.lock 解决了这个问题

I had the same problem on macOS, I have solved it by removing repo_folder/.git/index.lock

萌辣 2024-09-26 02:16:57

我在 .git\index.lock 上使用了 Unlocker 来解锁任何句柄由其他进程保持打开状态。就我而言,它是 TgitCache.exe。

I used Unlocker on .git\index.lock to unlock any handles that are held open by other processes. In my case it was TGitCache.exe.

命比纸薄 2024-09-26 02:16:57

我在 Windows 10 中使用 git,通过清除系统的临时目录解决了这个问题。

正如这里的大多数回复所暗示的那样,这是一个与磁盘空间相关的问题。

I'm using git in Windows 10, and this issue was resolved for me by clearing the system's temp directory.

As most replies here suggest, it's a disk-space related problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文