git gc 错误:无法运行重新打包消息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18563246/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:53:11  来源:igfitidea点击:

git gc error: failed to run repack message

gitgarbage-collection

提问by ygoe

I've just run git gcon my local repository to do some regular clean-up. Today for the first time, it failed. Here's what I've done: (Windows 7)

我刚刚git gc在我的本地存储库上运行以进行一些定期清理。今天第一次失败了。这是我所做的:(Windows 7)

C:\Source\TxTranslation>git gc
Counting objects: 880, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (540/540), done.
Writing objects: 100% (880/880), done.
Total 880 (delta 504), reused 589 (delta 333)
rm: cannot unlink `pack-18179305b5b5dbdaf059e4ded50b736ab93e220c.pack': Permission denied

C:\Source\TxTranslation>git gc
Counting objects: 880, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (369/369), done.
Writing objects: 100% (880/880), done.
Total 880 (delta 504), reused 880 (delta 504)
mv: cannot move `/c/Source/TxTranslation/.git/objects/pack/pack-3002d22690e007a4205f6ecfa19d6e93296fdd78.pack' to `/c/Source/TxTranslation/.git/objects/pack/old-pack-3002d22690e007a4205f6ecfa19d6e93296fdd78.pack'
error: failed to run repack

I can retry it as often as I want, I always get the second output again. The "permission denied" error above is nonsense. I believe it's a common spurious error that I see on many Windows systems these days. It may be coming from virus scanners that keep files open so that they can't be deleted immediately. That leads to all sorts of issues but apparently can't be avoided.

我可以随时重试,我总是再次获得第二个输出。上面的“权限被拒绝”错误是无稽之谈。我相信这是我现在在许多 Windows 系统上看到的常见虚假错误。它可能来自病毒扫描程序,它们使文件保持打开状态,因此无法立即删除它们。这会导致各种问题,但显然无法避免。

Is this a problem? Is something broken? I absolutely don't understand what those message mean to me. Browsing the log with diffs still works. What could I do to fix that problem? (Luckily I have pushed everything to Github just before, so I could simply re-clone it, but I'd like to try fixing it first, in case it happens again.)

这是一个问题吗?东西坏了吗?我完全不明白这些信息对我来说意味着什么。使用差异浏览日志仍然有效。我能做些什么来解决这个问题?(幸运的是,我之前已将所有内容推送到 Github,因此我可以简单地重新克隆它,但我想先尝试修复它,以防再次发生。)

采纳答案by ygoe

As it turned out, Visual Studio had a lock on some of Git's files. Closing Visual Studio resolved the issue.

事实证明,Visual Studio 锁定了一些 Git 文件。关闭 Visual Studio 解决了该问题。

FTR, I'm using the Git source control provider (in the last usable version 0.6.4) in VS2010. Maybe this is part of the cause.

FTR,我在 VS2010 中使用 Git 源代码控制提供程序(在最后一个可用版本 0.6.4 中)。也许这是原因的一部分。

回答by jake.lange

In my case git gcwould fail to run repack after enumerating but it was successful when running with some additional options, git gc --aggressive --prune=now.

在我的情况下git gc,枚举后无法运行重新打包,但在使用一些附加选项运行时它是成功的,git gc --aggressive --prune=now.

回答by arunvg

I got the same issue using eclipse . The was accessing git repository through Eclipse as well as git bash.

我在使用 eclipse 时遇到了同样的问题。正在通过 Eclipse 以及 git bash 访问 git 存储库。

Solved by running the gc after closing eclipse

通过关闭 eclipse 后运行 gc 解决

Environment

环境

Windows 7

Windows 7的

Git 1.8.4.mysysgit.0

Git 1.8.4.mysysgit.0

Eclipse Kepler SR2

日食开普勒SR2

回答by rakslice

If you were doing some other operation with git, or some git-related operation in a GUI, cancel the operation or close the error, and manually run a git gc, then try your operation again. Basically, on Windows, this message is an indication of contention between the git command line client and some other program.

如果您正在使用git或 GUI 中的某些与 git 相关的操作进行其他操作,请取消该操作或关闭错误,然后手动运行 a git gc,然后重试您的操作。基本上,在 Windows 上,此消息表明 git 命令行客户端和其他一些程序之间存在争用。

In my case, the repack had been triggered automatically as part of a git pull. When I got the error, after ruling out a permission issue with a quick sanity check that none of the things that would be launching git processes (IDE, git bash, git GUI) would be running elevated, I went to Process Explorerto find out what process had the file open (Find -> File Handle or DLL), and it found a git.exethat was a parent of the other git.exeprocess. I'm guessing that there are some locking assumptions in the automatic repack code that aren't appropriate on Windows, where, by default, opening a file puts an exclusive read/write lock on the file at the OS level.

就我而言,重新打包已作为git pull. 当我收到错误时,在通过快速健全性检查排除了权限问题后,没有任何启动 git 进程(IDE、git bash、git GUI)的东西会被提升运行,我去进程资源管理器找出哪个进程打开了文件(查找 -> 文件句柄或 DLL),并且它找到了git.exe另一个git.exe进程的父进程。我猜测自动重新打包代码中有一些不适合 Windows 的锁定假设,默认情况下,打开文件会在操作系统级别对文件进行独占读/写锁定。

That was with

那是与

$ git --version
git version 1.9.2.msysgit.0

回答by Dave Hogan

Hope this helps others.

希望这对其他人有帮助。

In my case I found that Tortoise Git process was the culprit for locking files. Terminating the process allowed me to git gc

就我而言,我发现 Tortoise Git 进程是锁定文件的罪魁祸首。终止进程允许我git gc

回答by Mark Brownsword

In my case a running IISExpress instance was to blame.

在我的情况下,一个正在运行的 IISExpress 实例是罪魁祸首。

回答by mfugel

This happened to me even AFTER I closed my solution in Visual Studio, but was resolved when I finally closed VS. I was NOT using the git source control extension.

即使在我在 Visual Studio 中关闭我的解决方案之后,这也发生在我身上,但是当我最终关闭 VS 时解决了。我没有使用 git 源代码控制扩展。