file - How to remove unused objects from a git repository? -


I accidentally pushed, committed and pushed a huge binary file to a grate store with my very latest commitment. .

How can I remove the object from the object that was created to do this, then my .git directory again reduces the size of a size ?

Edit : Thank you for your reply; For example, one of GitHub removed the files from history, but the .git directory size has not decreased:

  $ BADFILES = $ (check test_data-type F -exec echo -n "'{}'" \;) $ git filter-branch --index-filter "git rm -rf-cached --ignore- Unmatch $ badfs "Top rewrite 14ed3f41474f0a2f624a440e5a106c2768edb67b (66/66) rm 'Test_data / images / 001.jpg' [... link ...] rm 'test_data / images / 281.jpg' Ref Refs / head / master ' Rewrite $ git log -p # Good looks $ rm -rf .git / refs / original / $ git reflog end - Total $ git gc - a Resiv --prveen calculation of objects 625, the use of delta compression to 2 threads. Compressing objects: 100% (598/598), Written object written: 100% (625/625), done. Total 625 (Delta 351), re-0 (delta 0) $ du -hs .git 174m .git $ # still 175 MB :-(  

I answered this somewhere else, and it will be copied from here because I'm proud of it!

... and further Without a stir, can I offer you this useful script, GIT-GC-all, guaranteeing the removal of all their git trash until they can come with additional configuration variables I:

  git -c Gc.reflogExpire = 0 -c gc.reflogExpireUnreacable = 0 \ -c gc.rerereresolved = 0 -c gc.rerereunresolved = 0 \ -c gc.pruneExpire = Now GC "$ @"  

- The Overriding option can be helpful.

Note: This is all unrelated Do not cry to me, so if you later decide that you want to keep some of them!

You may need to run anything like before, oh dear, GIT is complex !

  Remote RM Ut Tti RM-RF Kgit / re each reference FS / original / .git / refs / remotes / .git / * _ HEAD .git / logs / git = "% (refname)" refs / original / | Xargs -n1 --no-run-if-empty git update-ref -d  

I put all this in a script, here:


Comments