I have encountered my first request to run git gc
. The message I received on my last commit was:
warning: There are too many unreachable loose objects; run 'git prune' to remove them.
and ...
You may also run "git gc" manually. See "git help gc" for more information.
So my question is do I run git gc --aggressive
, --auto
--prune
, or --quiet
?
Essentially I am concerned that I might lose any commit history or disrupt my master branch in any way.
Any recommendations?
In general, git gc
is safe to run. It won't throw away any commits reachable from any named reference. Depending on how you've set the appropriate expiration variable (e.g., gc.pruneexpire
, gc.reflogexpire
, etc.) it will possibly throw away commits that are only reachable from the reflog, or aren't reachable at all. I let git gc
decide when to prune on its own (looking at those expire settings) and usually do a git gc --aggressive
. It displays some stats while it's working. If you don't want to see those, then add --quiet
.