Script to remove commits older than a specified date
How can I delete commits older than X days?
The reason I want to do this is because the repo has gotten a pretty big value, filtering and gc no longer help, and we no longer need commitments over 5 years old. There are only 4 developers in this repo.
Is there a script that can automate this?
source to share
I get two options:
-
Create a new repository by cloning the original repo using an argument
--depth=N
; it will create a new history, keeping in history onlyN
. Then all developers will move to this new repository.To find out what should be
N
you can use the followinggit log --format=oneline HEAD@{5 years ago} | wc -l
This, however, will overwrite all your SHA1 transactions.
-
To keep your SHA1, you would use
git replace
splitting the story in two, following this blog post .
source to share