为什么git运行“git gc --auto”每次合并? [英] Why does git run "git gc --auto" on every merge?

查看:1072
本文介绍了为什么git运行“git gc --auto”每次合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,git在每次合并之后坚持运行 git gc ,开始表现得有趣(好吧,比平时更有趣),即使它们紧密相连。

  C:\Projects\my-current-project> git pull 
remote:计数对象:31,完成。
remote:压缩对象:100%(16/16),完成。
remote:合计16(delta 11),重用0(delta 0)
开箱对象:100%(16/16),完成。
从git.company.com:git/
e992ce8..6376211 mybranch / next - > origin / mybranch / next
通过递归进行合并。
自动打包存储库以获得最佳性能。您也可以手动运行git gc。有关更多信息,请参阅git help gc。
FIND:参数格式不正确
计数对象:252732,完成。
使用多达2个线程的增量压缩。
压缩对象:100%(59791/59791),完成。
写作对象:100%(252732/252732),完成。
共计252732(增量190251),重用252678(增量190222)
删除重复对象:100%(256/256),完成。
... / stylesheets / style.css | 2 + -
1个文件已更改,1个插入(+),1个删除( - )

这是令人难以置信的破坏性,我担心这意味着我的存储库不知何故(这是我第一次自动地看到它 gc )。我的担心是否没有根据?如果我的存储库没问题,我该如何让自动包装停止?



我想我发现了这个问题。

您可能在Windows上运行Cygwin / git或MsysGit。我注意到由于

  FIND:参数格式不正确

错误讯息。问题在于你的钩子脚本(或git内部?!)正在调用find,它找不到UNIX(GNU)查找实用程序,而是找到Windows(MSDOS ... sic)FIND.EXE。

您应该可以修复您的系统范围路径。如果这不是一个选项,请在脚本中明确指定PATH环境变量(或在调用它们之前)。




以供参考:



git gc --auto 并不总是导致采取任何行动;你确定每次都需要时间,或者你刚刚注意到它被调用了?



如果每次都调用它,你可能会b
$ b


  • 检查存储库权限(确保它完全可写入您的!)
  • git fsck

  • git的重新包装

  • GIT中束--create mybundle.git --all GIT中克隆mybundle.git 以查看您是否可以'摇动'罪魁祸首

  • 查看您是否可以升级到更高版本

  • 如果所有其他操作都失败,则对git-gc二进制文件进行strace或debug



可选地,当你动摇罪魁祸首时,能够分析你的'已清理'回购和当前回购之间有什么不同。

git的-GC手册页




使用这个选项,git gc检查是否有任何管家需要红;如果没有,则退出而不执行
任何工作。一些git命令在执行可能会创建许多松散的
对象的操作后运行git gc --auto。



如果有太多松散物体或者太多存储库中的许多包。如果松散对象的
数量超过gc.auto配置变量的值,则使用git repack -d -l将所有松散对象
合并为一个包。将gc.auto的值设置为0将禁用
自动填充松散物体。



如果包数超过gc.autopacklimit的值,则存在包(使用.keep文件标记
的包除外)通过使用git repack的-A选项合并为一个包。
gc.autopacklimit设置为0,禁止包的自动合并。





Today, git started acting funny (well, funnier than usual) by insisting on running git gc after every single merge, even if they are back to back.

C:\Projects\my-current-project>git pull
remote: Counting objects: 31, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 16 (delta 11), reused 0 (delta 0)
Unpacking objects: 100% (16/16), done.
From git.company.com:git/
   e992ce8..6376211  mybranch/next -> origin/mybranch/next
Merge made by recursive.
Auto packing the repository for optimum performance. You may also run "git gc" manually. See "git help gc" for more information.
FIND: Parameter format not correct
Counting objects: 252732, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (59791/59791), done.
Writing objects: 100% (252732/252732), done.
Total 252732 (delta 190251), reused 252678 (delta 190222)
Removing duplicate objects: 100% (256/256), done.
 .../stylesheets/style.css                          |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

This is incredibly disruptive, and I fear that it means that my repository is corrupt somehow (this is the first time I've ever seen it automatically gc). Are my fears unfounded? If my repository is OK, how do I make the auto-packing stop?!

解决方案

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 and git 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, 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.

这篇关于为什么git运行“git gc --auto”每次合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆