rtyley / bfg-repo-cleaner

Removes large or troublesome blobs like git-filter-branch does, but faster. And written in Scala
https://rtyley.github.io/bfg-repo-cleaner/
GNU General Public License v3.0
10.95k stars 540 forks source link

Does not work for git submodules #315

Open racinmat opened 5 years ago

racinmat commented 5 years ago

I use git submodules and I needed to remove big file from one of the submodules so I can push it to github. I removed the file in one commit, so it is not longer in current files, but running bfg did not help, it still kept the file in history.

liangjacky commented 5 years ago

@racinmat if you are using submodules, you should run bfg in the submodule repo, push the changes, and then update the ref in the parent repo to use the clean version.

You cannot run bfg from the parent repo as all submodules are is a reference to a commit in the submodule repo.

mccoy1 commented 4 years ago

If I needed to run BFG in both a parent repo and a submodule repo, I undestand I would probably have to update the parent repo to point to the latest clean commit in the submodule. But does BFG preserve the association between the two in the history? Or by changing all of the commit ids, would the history of the parent-child relationship be lost? UPDATE: Confirmed through testing that the parent-child relationship b/w parent and child repos would be lost running BFG.

TorrentialFire commented 4 years ago

BFG produces a file which contains the mapping from the old commit hash to the new commit hash. I have solved this problem in my production repositories by writing a java tool (using the JGit library) to rebuild the history of the parent repository with the new refs. This requires some creativity and a good deal of knowledge of git porcelain to do, but it is possible. I wrote the original code for work, unfortunately.