What can/should I do about this git gc error? (rm: cannot unlink pack Permission denied)

danludwig picture danludwig · May 5, 2012 · Viewed 14.7k times · Source

When running git gc, I keep seeing this error:

rm: cannot unlink 'pack-30b1ff2[reset of hash].pack': Permission denied

What can/should I do about this error?

Update

Sorry, I should have provided more info. Yes, I have tried a reboot. In fact,reboots have fixed gc issues for me before.

I only noticed this issue because when I open Git Gui, it prompts me now and then to compress the database. I eventually noticed that after a couple of times opening Git Gui that it kept prompting me, even though I clicked Yes, and it came back "successful".

So then I tried running it with Git EXT's Settings - Git maintenance - Compress git database command. This command told me that there was an error (red light in Git EXT whereas there was a green light in Git Gui).

The error I posted above however was from running git gc straight from git bash.

Should I schedule a disk scan? Could bad sectors be causing this? I was hoping this would be a quick answer :(

Answer

Dmitry Ovsyanko picture Dmitry Ovsyanko · May 5, 2012

"Permission denied" on Windows is often caused by a lock from a running process. It's probable that there is a stalled Git EXT thread opened the pack file.

Try to do the git gc in safe mode.

Another option is to clone the repository in a new place and delete the old one.