I want to extend the time old commits are kept around, to extend git’s default “grace period” before garbage collects occurs. I don’t want to keep all unreachable commits, such as the temporary, intermediate ones made during the process of a rebase, just those belonging at one time to past versions of a branch, across rebases. In other words, I want to keep past versions of each branch for longer than 30 or 90 days.
Which led me to the gc.pruneExpire
, gc.reflogExpire
and gc.reflogExpireUnreachable
settings.
My understanding is the as long as a commit is reachable from the reflog, which includes references to prior histories of each ref, then the gc.pruneExpire
value does not apply, which is about pruning commits.
If that is correct (please confirm), then what I need to do is control reflog pruning, via either gc.reflogExpire
or gc.reflogExpireUnreachable
.
But the distinction between the two is not obvious, which is to say, I don’t know what either means exactly. git config help
isn’t very clear:
gc.reflogExpire, gc.<pattern>.reflogExpire
git reflog expire removes reflog entries older than this time; defaults to 90 days. The value
"now" expires all entries immediately, and "never" suppresses expiration altogether. With
"<pattern>" (e.g. "refs/stash") in the middle the setting applies only to the refs that match
the <pattern>.
gc.reflogExpireUnreachable, gc.<pattern>.reflogExpireUnreachable
git reflog expire removes reflog entries older than this time and are not reachable from the
current tip; defaults to 30 days. The value "now" expires all entries immediately, and "never"
suppresses expiration altogether. With "<pattern>" (e.g. "refs/stash") in the middle, the
setting applies only to the refs that match the <pattern>.
These types of entries are generally created as a result of using git commit --amend or git
rebase and are the commits prior to the amend or rebase occurring. Since these changes are not
part of the current project most users will want to expire them sooner, which is why the default
is more aggressive than gc.reflogExpire.
I don’t understand “not reachable from the current tip”, because I thought the whole point of the reflog is to track old, not current, refs. Also confusing is “the commits prior to the amend or rebase occurring”, because, again, I thought that was what the reflog was about, what references pointed to prior to rebases or amends.
To reiterate, i want to keep a history of past versions of a ref, across all rebases, for longer than 90 days. Which setting should I set?
(tangential question: is setting it to ’12.months.ago’ a bad idea?)