Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep Git Reflog Indefinitely?

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?

like image 355
haziz Avatar asked May 02 '12 22:05

haziz


People also ask

How long does Reflog last?

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 .

Which option limits git Reflog expire to the current working tree?

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.

Does Reflog get pushed?

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.

How are references removed from the Reflog other than through the 90 day limit?

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} ).

What is the difference between git log and git Reflog?

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.


1 Answers

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>.

like image 110
sehe Avatar answered Sep 22 '22 18:09

sehe