Why does git run "git gc --auto" on every merge?
EDIT
I think I spotted the problem.
You are probably running Cygwin/git or MsysGit on Windows. I noticed that because of the
FIND: Parameter format not correct
error message. The trouble is that somewhere your hook scripts (or git internally?!) is calling find, which does not find the UNIX (GNU) find utility but rather finds the Windows (MSDOS... sic) FIND.EXE.
You should be able to fix your system wide path. If that is not an option, explicitely specify the PATH environment variable inside your script (or before invoking them)
Old answer for information:
git gc --auto
does not always result in any action taken; are you sure this is taking time every time, or did you just notice it is being called?
If it is being called every time, you might
- check repository permissions (make sure it is fully writable to you!)
- git fsck
- git repack
git bundle --create mybundle.git --all
andgit clone mybundle.git
to see whether somehow you can 'shake' the culprit- see whether you can upgrade to a later version
- if all else fails, strace or debug the git-gc binary
Optionally, when you have shaken the culprit, you maybe able to analyze what is different between your 'cleaned' repo and the current one.
From the git-gc man-page:
With this option [--auto], git gc checks whether any housekeeping is required; if not, it exits without performing any work. Some git commands run git gc --auto after performing operations that could create many loose objects.
Housekeeping is required if there are too many loose objects or too many packs in the repository. If the number of loose objects exceeds the value of the gc.auto configuration variable, then all loose objects are combined into a single pack using git repack -d -l. Setting the value of gc.auto to 0 disables automatic packing of loose objects.
If the number of packs exceeds the value of gc.autopacklimit, then existing packs (except those marked with a .keep file) are consolidated into a single pack by using the -A option of git repack. Setting gc.autopacklimit to 0 disables automatic consolidation of packs.
Your repository should have a lot of objects that the hashes start with 17. So this triggers git gc --auto. Default is at least 28 objects prefixed 17.
I'm adding this answer even though it doesn't answer the original poster's specific problem because every time one of my repos starts auto-packing after every merge I've forgotten the fix, search for it again and find this question first.
When one of my repos starts "Auto packing the repository for optimum performance" after every merge,
git gc --prune=now
fixes it. (Being on a Mac, I don't have the FIND: Parameter format not correct
problem.) Right now I'm using git 2.4.1, but this has worked for me for several 2.* versions.
This answer to How to remove unreferenced blobs from my git repo suggests that one might need to clear one's reflog with
git reflog expire --expire-unreachable=now --all
for the above command to be maximally effective, but I've never needed to do that to fix auto-packing after every merge.
What version of git are you using? Regardless, I find automatic gc
ing extremely disruptive.
git config --global gc.auto 0