To my knowledge there is no such thing in git
as a built-in setting for 'max-history-length', i.e. a maximum number of commits after which the oldest ones will start to be 'dropped' into oblivion and the depth would be automatically adjusted in some sort of 'lossy history' compression, similar to how git clone --depth=42
limits the number of commits to include into a local 'lossy' clone.
Are there alternative ways of achieving an automatic or semi-automatic truncation of old commits in a repo in a way that will not require push --force
?
I am aware of approaches like git clone --depth=1
or git-filter-repo
as covered in other questions:
- Reduce git repository size
- Compact Git repository with history depth
- How do I remove the old history from a git repository?
All of these solutions require manual interventions that need to be applied on a regular basis. Is there a better way that would achieve the objective of keeping a maximum of NN commits in a live repo while still allowing it to be synched in the usual way while preventing it from growing indefinitely?