在我本地的公司代码库副本上(我经常创建很多短期分支并频繁使用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)$
也就是说:我输入 git pull
命令后,Git 会返回一大堆信息,其中包含两个必须的命令,我需要手动执行这些命令才能继续我的工作。
如果 Git 能够自动帮我执行那些命令,而不是强制我复制和粘贴它们,那就太好了。我知道这不是 git pull
的默认行为,但这似乎应该是一个可以添加到我的 .gitconfig
文件中的选项。是否存在这样的选项?
git gc
没有做正确的事情的唯一原因是我的git reflog
太大了,因为我经常进行激进的变基(而仍在 reflog 中的内容不会被 gc,但它们会被 prune)。如果“减少我的 reflog 的默认保留策略”既可行又足以解决我的问题,那么我将接受一个只描述如何执行此操作的答案。 - Quuxplusonegit config --get extensions.preciousobjects
的输出是什么?(这是在 Git 2.7.0 中引入的功能,它可以防止git gc
剪切对象。) - torekgit config --get extensions.preciousobjects
返回空值并返回退出码1。git --version
输出git版本2.9.3
。 - Quuxplusone