git gc error: failed to run repack message

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

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.


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.


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


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

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