Bfg-repo-cleaner: Feature request: delete all history older than a certain date

Created on 26 Jan 2018  路  2Comments  路  Source: rtyley/bfg-repo-cleaner

Some projects have no need for file/commit history beyond a few months. And in my case, a project has some small binary files which still have to be committed. Over months of frequent usage, the data can add up to a non-negligeable size.

Could BFG provide an option like "delete all commits older than X days", that would trim the repo by deleting unneeded old history? The first commit from X-1 days ago would then become the first commit of the project. Any branches which have had no commits since X-1 days ago would be deleted (or not...maybe it should be an option).

Most helpful comment

This is a fairly unusual requirement and usage-pattern for Git. It is not typical to want to regularly discard all or most of your source-code history based on its age. For that reason, Git is not designed to make this a simple or pleasant process.

Rewriting history (such as to delete large files) is very much something that you want to do rarely, if-ever. Used once it can help atone for "sins of the past", but you really want to stop adding the wrong sort of content to the repo. When you rewrite history, all developers will need to re-clone the repo and rewrite all of their WIP onto the new history.

What you really need to do is to adopt a proper solution for your binary files - a binary repository, or Git LFS or something else. Stop committing them to Git.

If you really want to do this, you don't need BFG for it, and it won't help much. I'd recommend just squashing everything down to a new root commit, and keeping the previous repo as a history reference for a while.

All 2 comments

This is a fairly unusual requirement and usage-pattern for Git. It is not typical to want to regularly discard all or most of your source-code history based on its age. For that reason, Git is not designed to make this a simple or pleasant process.

Rewriting history (such as to delete large files) is very much something that you want to do rarely, if-ever. Used once it can help atone for "sins of the past", but you really want to stop adding the wrong sort of content to the repo. When you rewrite history, all developers will need to re-clone the repo and rewrite all of their WIP onto the new history.

What you really need to do is to adopt a proper solution for your binary files - a binary repository, or Git LFS or something else. Stop committing them to Git.

If you really want to do this, you don't need BFG for it, and it won't help much. I'd recommend just squashing everything down to a new root commit, and keeping the previous repo as a history reference for a while.

I can explain a close situation:
In my company, we were migrating the base code from GitLab to GitHub.
Apparently GitHub has a 100MB file size limit.
After manually cleaning the large files from GitLab HEAD,
My job was to set up a sync job between the GitLab and the GitHub repo,
so the GitHub repo will mirror the GitLab repo,
but on GitHub I would like to preserve the commits created only after the day I cleaned the GitLab repo.
Any solution?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitchellkrogza picture mitchellkrogza  路  5Comments

dwabyick picture dwabyick  路  8Comments

Adnansamiuu picture Adnansamiuu  路  4Comments

dpopiashvili picture dpopiashvili  路  5Comments

rlam3 picture rlam3  路  5Comments