1

I earlier pushed many files to git, many of them where unwanted. I followed the following to remove those unwanted files (jar/lib/ide files etc).

Remove Files - 1

Remove Files - 2

Basically I did,

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch target'

I verified in github those files don't exist anymore. When I download my repo as zip in github its less than 1MB, however when I do a git clone, its still 100MB.

Upon further research I found after cloning,

MyRepo/.git/objects/pack/pack-b6b2b82ecd58c551c3648b9ca97e4f8b29rrt3c2.pack is 99.8 MB. How can I get rid of this?

Community
  • 1
  • 1
Himalay Majumdar
  • 3,883
  • 14
  • 65
  • 94

1 Answers1

1

It sounds like you missed the last step of the first link (step 9):

git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now

The git gc garbage collects.

I'd add that you should make sure you do not accidentally git push back the bloated content. I suggest removing local copies of all repositories and recloning once you are sure it works.

The second link you suggested almost entirely deals with removing the file from the repository as a commit; if you do this, you will still be able to check out a revision prior to the commit, so the contents of the file must obviously still be somewhere, hence your git clone does not reduce in size.

abligh
  • 24,573
  • 4
  • 47
  • 84
  • Tried all the steps again, doesn't work. I will probably find a manual work around, but I am curious how to get rid of it. – Himalay Majumdar Jan 04 '16 at 14:36
  • Is it possible that at some stage in the past the file had a different name? You might want to check `git filter-branch` was applying the filter to all branches. – abligh Jan 04 '16 at 14:42
  • I am seeing, WARNING 'refs/remotes/origin/master' is unchanged , WARNING: Ref 'refs/heads/master' is unchanged. I think its because I had earlier deleted the unnecessary files using `git rm -r --cached .idea`. – Himalay Majumdar Jan 04 '16 at 17:22
  • Try `git reset --hard [commit]` first. – abligh Jan 04 '16 at 17:32