0

The last few times I have committed changes to a local repo via TortoiseGit, I see this message for 30-60s:

Auto packing the repository in background for optimum performance.

What that means is explained here: What does "Auto packing the repository for optimum performance" mean?

But after about 60s I get a load of these errors:

--------------------------- Unlink of file '.git/objects/pack/pack-03733367d688c04acc63242e5034df85184933e5.pack' failed. Should I try again?

I don't know how many as I always give up, when I kill TortoiseGit the commit seems to have been performed correctly when I check the logs.

What can I do about this? Can I get Git to try and perform this packing in isolation, as I fear for my changes getting damaged?

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589

1 Answers1

4

The “auto packing the repository” message means Git is running git gc --auto to pack data in the repository for efficiency. Once the objects are packed into a pack file, the loose objects, like the one in the error message, are no longer needed and are removed.

Normally, this works fine. However, Windows has an intentional design decision where a file that is in use generally cannot be removed. This message means that Git is trying to remove the file which is no longer needed, but it cannot do so because some other program is using it and Windows doesn't permit that. This problem is not harmful to the integrity of your repository, but it is wasteful and inefficient, and the fact that the loose files cannot be removed means the git gc will continue to run frequently.

You'll need to find every program that's accessing your repository, whether that's a GUI, an editor, or something else, and quit it, then go into Git Bash, change directory to your repository, and run git gc. If that doesn't work, you can try restarting your computer to close all unused programs, then run git gc. It's possible that this could also be caused by third-party antivirus software or other software that monitors the system, in which case you should completely uninstall it, restart, and switch to Windows Defender.

There is, unfortunately, no other way to solve this problem, since this is an intentional design decision, albeit an improvident one, on the part of Microsoft.

bk2204
  • 64,793
  • 6
  • 84
  • 100