I have known that reflog entries gets deleted which are older than 90 days. I have not made any change in git config too regarding this.
Today when I did git reflog master --date=local
, I can see entries of 10 months before in it. How is that possible ?I should only be seeing entries dating back to 3 months before only ?

- 4,631
- 8
- 45
- 83
2 Answers
Git will automatically run git gc
periodically, provided you don't disable it. But the period for this automatic GC is not defined anywhere, and in fact, it's not based on time at all. Instead, it's based on a quick survey that git gc --auto
makes of the state of the repository. Moreover, it's actually kicked off by running some other Git command, which simply runs git gc --auto
at the end of its work. That git gc --auto
then decides whether to run git gc
, and if so, that git gc
runs git reflog expire
with the 90 day expiration.
In this case, perhaps either you have not run a Git command that ran git gc --auto
, or git gc --auto
chose not to do anything, for 10 months. That seems a bit excessive,1 so it's more likely you disabled automatic GC by setting gc.auto
to 0
. It's also possible you have hit an interesting bug: see this answer by VonC to one of the "see also" questions below, which has a fix for a bug that did bite people.
See also List of all commands that cause git gc --auto, Understanding git gc --auto, and How often should you use git-gc?
1How excessive this is depends on how active the repository is. A fairly quiet repo might not accumulate enough loose objects to make git gc --auto
do anything for many months; a busy one will need automatic gc pretty frequently.

- 448,244
- 59
- 642
- 775
How is that possible?
Pretty simple explanation - that is possible if you don't run git reflog expire
or git gc
regularly. If you did that and they are still there, please amend your question. Else, that's it.
Type git gc
and see them disappear.

- 8,048
- 1
- 21
- 36
-
@BreakingBenjamin, "I thought it is automatically done after 90 days ?" - it does not seem to happen in the pretty standard local dev repository I am using in my most active project right now; tried it before the answer, and yup, the reflogs were there. Not back up to the beginning of time, but about 5 months worth. I do not recall when I ran `git gc` in that respository last time, could well be that that was 5 months ago. – AnoE Oct 10 '18 at 16:34