Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

keep reflog for deleted references

Tags:

git

git-reflog

On my local clone of a git repo, when a reference is deleted (or renamed), the reflog attached to the old name is deleted.

I couldn't find an option which states "keep log for deleted references".

Question

Is there a way to keep the reflog files for deleted references ?

Cleaning and gc could still follow the parameters for reflog entries, unreachable objects, etc ...

like image 852
LeGEC Avatar asked Oct 15 '25 16:10

LeGEC


1 Answers

As far as I can tell, git does not provide a way to do this. I don't know the reasoning; it would of course be nice to keep the branch's reflog for the usual retention period, but not knowing the nuts and bolts of how reflog expiration normally works I can't say if there's a solid reason why that would be too difficult. (Or maybe it would be a problem in the event a new branch with the same name is created?)

Whatever the reason, the docs specify that the log is deleted (https://git-scm.com/docs/git-branch) and do not indicate any way to change the behavior. I guess you could manually copy the reflog file (.git/logs/refs/...) to preserve the information, but it's certainly not a user-friendly approach.

In practice, you're basically limited to whatever entries might incidentally be in the HEAD reflog. So, I guess if you're not sure that you no longer need a more detailed history of the branch, don't delete it yet.

like image 91
Mark Adelsberger Avatar answered Oct 17 '25 04:10

Mark Adelsberger



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!