'git gc error: failed to run repack message
I've just run git gc on my local repository to do some regular clean-up. Today for the first time, it failed. Here's what I've done: (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.
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.)
Solution 1:[1]
In my case git gc would fail to run repack after enumerating but it was successful when running with some additional options, git gc --aggressive --prune=now.
Solution 2:[2]
I got the same issue using eclipse . The was accessing git repository through Eclipse as well as git bash.
Solved by running the gc after closing eclipse
Environment
Windows 7
Git 1.8.4.mysysgit.0
Eclipse Kepler SR2
Solution 3:[3]
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.
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 Explorer to find out what process had the file open (Find -> File Handle or DLL), and it found a git.exe that was a parent of the other git.exe process. 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.
That was with
$ git --version
git version 1.9.2.msysgit.0
Solution 4:[4]
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
Solution 5:[5]
In my case a running IISExpress instance was to blame.
Solution 6:[6]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jacob Lange |
| Solution 2 | arunvg |
| Solution 3 | |
| Solution 4 | Dave Hogan |
| Solution 5 | Mark Brownsword |
| Solution 6 | mfugel |
