Reputation: 42454
By default git reflog is returning results from last 90 days. How I can go beyond it? I tried different ways to set --expire but its throwing error. Whats the proper way of using it?
I tried
git reflog --expire=all
fatal: unrecognized argument: --expire=all
then
$ git reflog --expire=2022-01-01 12:12:00
fatal: invalid object name '12'.
then
$ git reflog --expire=2022-01-01
fatal: unrecognized argument: --expire=2022-01-01
Upvotes: 3
Views: 3088
Reputation: 1780
I was able to use it like this:
$ git reflog expire --all
And also like this:
$ git reflog expire --expire 2022-01-01
And also like this:
$ git reflog expire --expire "2022-01-01 12:12:00"
That said, torek isn't wrong - this usually isn't needed.
Upvotes: 0
Reputation: 488461
Users should ordinarily not run git reflog expire
themselves. Instead, they should normally let git
commands run git gc --auto
, or if they want to force a garbage-collection pass now, run git gc
themselves without --auto
.
To make reflog entries last longer than the default 30 and 90 days, use git config
to set the expiry values, as described in the git gc
documentation.1 The main two knobs to set are gc.reflogExpire
and gc.reflogExpireUnreachable
, which default to 90.days
and 30.days
respectively.
Note that once an entry has passed its expiration date, the next git gc
that actually does anything is the one that removes the entries. Once they're gone, they are gone forever (unless you restore them from a system backup).
1Hiding these details in git help gc
(though they also appear in the git config
documentation) is one of the ways Git maintains its air of inscrutability. 😀 Seriously though, they're in that document because it's git gc
that handles the configured expiration. That's why you normally don't run git reflog expire
at all.
Upvotes: 4