2

A long time ago I committed a rather large folder which isn't really supposed to be in my repository, but I understood that only recently.

I found another question with a similar problem to mine and decided to try the chosen solution:

git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch unwanted_folder' --prune-empty
git gc --aggressive --prune

Luckily, I was smart enough to not try this on the folder itself (because it contains very important data), and tried this on a non important small file I had for a long time in my repository. The solution I tried ended up deleting the local copy of the file. Unfortunately I didn't check if it really was deleted from my repository's history because keeping my local copy was a higher priority.

So I backed up my local copy and tried the same process on it. It didn't work, the folder stayed in my history, and also in the .pack file which is practically the history (please correct me if I'm wrong).

Another potential solution I found was to use the "BFG Repo-Cleaner" tool. So I followed the exact instructions from their website (with my wanted filters of course: --delete-folders media for that matter), and guess what? It didn't work. Oh and another thing, my total repository size DOUBLED.

I really don't wanna start a new repository so -

please, help.

Eyal
  • 1,649
  • 3
  • 25
  • 49
  • All history-modifiers work (necessarily) by *copying* history to a new, alternative history. As such, depending on how far back the modifications have to reach, you should expect the repository size to increase, up to about 2x. To shrink the repository later, you stop using the old history and eventually it goes away on its own; or you clone the modified repository to a new one that carries *only* the new history, not both the old and new. – torek Jul 31 '17 at 21:47
  • @torek OK so first of all thank you for the explanation which seemed to lack in those solutions. Secondly, after I tried the first solution I didn't noticed any change in size, which only happened after I tried the second. How can clone my repository with the new history after I pushed to the remote? – Eyal Jul 31 '17 at 21:51
  • The bad thing about any of this is that *everyone* must start over with this new repository. In general, though, see the "checklist for shrinking" section at the end of [the `git filter-branch` documentation](https://www.kernel.org/pub/software/scm/git/docs/git-filter-branch.html). – torek Jul 31 '17 at 22:00
  • @torek Will do that as soon as I can and report back with the results. Thanks again. – Eyal Jul 31 '17 at 22:02

0 Answers0