git - 为什么 git 在每次 merge 时都运行 "git gc --auto"?

标签 git

今天,git 通过在每次 merge 后坚持运行 git gc 开始变得有趣(好吧,比平时更有趣),即使它们背靠背也是如此。

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(-)

这非常具有破坏性,我担心这意味着我的存储库以某种方式损坏(这是我第一次看到它自动 gc)。我的恐惧是没有根据的吗?如果我的存储库没问题,我该如何停止自动打包?!

最佳答案

编辑

我想我发现了问题。

您可能正在 Windows 上运行 Cygwin/git 或 MsysGit。我注意到,因为

FIND: Parameter format not correct

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

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


信息的旧答案:

<子>

git gc --auto 并不总是导致采取任何行动;您确定每次都需要时间,还是您只是注意到它正在被调用?

如果每次都被调用,你可能会

  • 检查存储库权限(确保它对您是完全可写的!)
  • git fsck
  • git 重新打包
  • git bundle --create mybundle.git --allgit clone mybundle.git 看看你是否能以某种方式“摆脱”罪魁祸首
  • 查看是否可以升级到更高版本
  • 如果一切都失败了,strace 或调试 git-gc 二进制文件

可选地,当您甩掉罪魁祸首时,您也许能够分析您的“已清理”存储库与当前存储库之间的不同之处。

来自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.

关于git - 为什么 git 在每次 merge 时都运行 "git gc --auto"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7392155/

相关文章:

Git: checkout 某些提交: "detached head"状态

git - 将光标移动到之前所在行的 vim 命令是什么?

git - 为什么我必须将现有的 Git 存储库设置为 "clone"才能访问它?

windows - 无法针对工作和个人环境分别自定义.gitconfig中的配置

Jenkins 管道内的 docker 内部的 Git 不起作用

wordpress - Git 从本地存储库推送到服务器上的远程存储库以进行 WordPress 部署

git - 如何在 GitHub 中仅使用我的分支存储库的主分支中的最新提交执行 pull 请求

git - 从 BitBucket 下载 Git 存储库

git lfs ls-files : Asterisk (*) vs. 破折号 (-)

git - 如何列出特定提交后的提交?