在我在公司范围内的存储库的本地副本(我在那里制作了许多短命的分支git rebase,而且很多其他人也在推动短暂的分支到origin我正在拉动),我经常有跟git交谈.
(env)$ git pull
remote: Counting objects: 382, done.
remote: Compressing objects: 100% (247/247), done.
remote: Total 382 (delta 182), reused 62 (delta 62), pack-reused 73
Receiving objects: 100% (382/382), 228.63 KiB | 0 bytes/s, done.
Resolving deltas: 100% (232/232), completed with 15 local objects.
From github.com:anon/anony2
aee962f..055a717 master -> origin/master
[...]
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
error: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.
warning: There are too many unreachable loose objects; run 'git prune' to remove them.
Updating aee962f..055a717
Fast-forward
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
error: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.
warning: There are too many unreachable loose objects; run 'git prune' to remove them.
[...]
9 files changed, 128 insertions(+), 95 deletions(-)
(env)$ git prune
Checking connectivity: 772524, done.
(env)$ rm .git/gc.log
(env)$
Run Code Online (Sandbox Code Playgroud)
```
那就是:我说git pull; git向我吐了一堆东西,有用地包括我需要运行的两个命令; 我运行这些命令; 然后我可以继续我的工作.
如果git只是为我运行这些命令,而不是强迫我剪切并粘贴它们,那将是非常棒的.我知道这不是默认行为git pull,但它似乎可能存在作为我可以添加到我的选项的那种东西.gitconfig.这样的事情存在吗?
问题很可能是您生成的松散对象足够快,实际上超出了以下的默认git gc保护时间2.weeks.ago:
--prune=<date>
修剪比日期更早的松散对象(默认为2周前,可由config变量覆盖gc.pruneExpire).--prune =所有修剪松散的对象,无论其年龄如何(不要使用--prune = all,除非你确切知道你在做什么.除非存储库处于静止状态,否则你将丢失尚未锚定的新创建的对象引用并最终破坏您的存储库).--prune默认开启.
这里发生的是git gc在后台自动修剪松散的对象及其默认机制,即运行git prune --expire=2.weeks.ago(或任何你配置的gc.pruneExpire).但这留下了足够松散的物体,git gc认为它在修剪方面做得很差.
运行git prune没有到期时间(如在手册git prune),或用--prune=all在git gc,除去所有松散物.如果没有其他Git命令正在运行,这是安全的.由于git gc --auto在后台运行,它需要一个安全边际 - 但两个星期对你的使用来说太多了.
如果您确信您的各种Git命令将仅仅一个星期,甚至也许是一天完成,:-)你可以配置gc.pruneExpire到1.week.ago或1.day.ago使其修剪更积极.除非你生成了大量的松散物体,否则可能就是这样:
$ git config gc.pruneExpire 3.days.ago
Run Code Online (Sandbox Code Playgroud)
请注意,以这种方式设置时,只更改此存储库的设置,并覆盖任何更多全局设置.要么:
$ git config --global gc.pruneExpire 1.week.ago
Run Code Online (Sandbox Code Playgroud)
这会将您的个人(用户全局)默认值设置为一周,而不是两周(但如果已设置,则会被特定于回购的"三天"设置覆盖).
检查所有这些extensions.preciousObjects没有记录的时候我注意到了.(与所有配置变量一样,这可以拼写为任意大小写混合.)它是在Git 2.7.0中添加的,它允许您阻止对象的所有自动修剪,如果您设置共享存储库,则可能需要这些修剪.(使用起来很棘手,可能不是任何临时用户应该设置的东西.)
| 归档时间: |
|
| 查看次数: |
7890 次 |
| 最近记录: |