I tend to be a bit paranoid about my data, including the ability to recover it.
Git reflog data is pruned after 30 days. Is there a way of setting it so that the reflog data is maintained and kept indefinitely?
Any major advantage or disadvantage (other than space or speed considerations) to doing so?
By default, the reflog expiration date is set to 90 days. An expire time can be specified by passing a command line argument --expire=time to git reflog expire or by setting a git configuration name of gc. reflogExpire .
Options for expire By default when --all is specified, reflogs from all working trees are processed. This option limits the processing to reflogs from the current working tree only.
The reflog is strictly local and isn't part of the repository. It's also not included in pushes, fetches, or clones. Git uses the git reflog tool to keep track of changes made to branch tips. It lets you go back to any commit, even if it isn't referenced by any branch or tag.
The subcommand expire is used to prune older reflog entries. To delete single entries from the reflog, use the subcommand delete and specify the exact entry (e.g. git reflog delete master@{2} ).
The biggest difference between Git reflog vs. log is that the log is a public accounting of the repository's commit history while the reflog is a private, workspace-specific accounting of the repo's local commits. The Git log is part of the Git repository and is replicated after a push, fetch or pull.
Caveat: reflogs are local and are not sent/received with push/pull operations.
Cons: reflogs may result in (otherwise) unreachable snapshots (and consequently blobs) being kept around, growing your repo to larger sizes than might be desirable. Look at gc.reflogexpireunreachable
for something that may help in this respect.
Two configuration settings govern the expiration of reflog entries:
gc.reflogexpire
,gc.<pattern>.reflogexpire
git reflog expire removes reflog entries older than this time; defaults to 90 days. With "<pattern>" (e.g. "refs/stash") in the middle the setting applies only to the refs that match the .
gc.reflogexpireunreachable
,gc.<ref>.reflogexpireunreachable
git reflog expire removes reflog entries older than this time and are not reachable from the current tip; defaults to 30 days. With "<pattern>" (e.g. "refs/stash") in the middle, the setting applies only to the refs that match the <pattern>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With