安全运行git gc

Vol*_*ony 5 git garbage-collection

我遇到了第一个运行git gc的请求。我上次提交时收到的消息是:

warning: There are too many unreachable loose objects; run 'git prune' to remove them.
Run Code Online (Sandbox Code Playgroud)

还有...

You may also run "git gc" manually. See "git help gc" for more information.
Run Code Online (Sandbox Code Playgroud)

所以我的问题是怎样运行git gc --aggressive--auto --prune--quiet

本质上,我担心我可能会丢失任何提交历史记录或以任何方式破坏我的master分支吗?

有什么建议吗?

Wol*_*olf 5

一般来说,git gc运行安全。它不会丢弃任何命名引用可到达的提交。根据您如何设置适当的到期变量(如gc.pruneexpiregc.reflogexpire等),这将有可能丢掉来自引用日志仅到达,或者是不是在所有可达的提交。我让git gc自己决定何时修剪(查看那些过期设置),通常会做一个git gc --aggressive。它在工作时会显示一些统计信息。如果您不想看到这些,请添加--quiet