Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git reflog expiration time

Tags:

git

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 ?

like image 970
Number945 Avatar asked Oct 21 '25 18:10

Number945


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.

like image 60
torek Avatar answered Oct 23 '25 06:10

torek


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.

like image 44
AnoE Avatar answered Oct 23 '25 06:10

AnoE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!