Reputation: 1389
Let us consider a test repository, which has README.md file. Commit a large file to it using another branch and raise pull request against master. Now you realize you accidently checked in some large files, so you raise another pull request to master and then merge it. Now your repository doesn't have any large files, but that accidental commit has led to a really .pack file in .git objects.
Bfg comes to rescue, which will fix this. Here are the steps to fix this:
--mirror
flag, this is imporant other wise remote branches will not get updatedjava jar path/to/bfg.jar --delete-files 'somelargefile.zip'
git reflog expire --expire=now --all && git gc --prune=now --agressive
git push --force
Alright now you have a clean repository. But there is a issue, your repository was being used by many folks and they have also cloned the repository and even made branches out of the master branch which still has the large .pack file in their local.
After doing above steps, it will affect all remote branches, those who were working on some branch, will need to take latest pull.
Let's say they take latest pull so that they can push more code in their branch, so locally they already have that branch, they do git pull and they will get error:
ERROR:
You have divergent branches and need to specify how to reconcile them
So they will need to merge/rebase/ff, either way, after pulling if they commit again, the large .pack file gets included again. How to fix this ? it just creates a infinite loop, you clean the repository using bfg and again someone pushes a commit and it is included again!!, how can someone avoid this ? the only way I can think of is that every one will need to re-clone a new repository and delete existing locally, is there any other way to fix this? more over can we also add some restriction in git hooks itself so that large files don't get checked in again (even if it is in .pack git history) ...
Upvotes: 0
Views: 52