0

I am trying to delete some big file (512MB) from my repo. As I noticed git rm bigfile removes file only from recent commint.

So I found some command: git filter-branch --index-filter 'rm -f bigfile' -- --all. And it succefully deleted file from all commits.

But repo still has big size du -hs . reports 512MB. There is some file in .git/objects/pack/pack-a8e5a5ed17f31ed45ea7f387245265206e4f4c39.pack which has 512MB. Is it safe to delete it manually or is there some git command how to clear it?

T0maas
  • 422
  • 2
  • 12
  • Because git retains objects for a while unless they get expired after a certain amount of time. Inspect your local refs first by using `git show-ref`, then delete unnecessary ones if any (be careful) by using `git update-ref -d`, and then collect git repository garbage by using `git clear` (if you don't care about the reflog). – terrorrussia-keeps-killing Jan 09 '22 at 15:59
  • Command `git show-ref` shows only: `a2c2fb06ef3e81f19f3243a3e804e123db7d52f2 refs/heads/master`. – T0maas Jan 09 '22 at 16:06
  • https://stackoverflow.com/a/43640996/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+compress – phd Jan 09 '22 at 16:08
  • Thanks, so this worked: ``` git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch bigfile" -- --all rm -rf .git/refs/original/ git reflog expire --expire=now --all git gc --prune=now git gc --aggressive --prune=now ``` – T0maas Jan 09 '22 at 16:23

0 Answers0