Somewhere along the line, some huge, huge file got added to the git repository of a project I own. When I go to clone this project on a new machine, the project appears to get “stuck” on 37% for a loooong time. This project should clone in just a couple of minutes.
How can I find out what object(s) are causing this lengthy cloning time?
I know how to “git rm” files. Will that remove it, even if it is some old object that only exists in the history?
I am not really clear if, once you “git rm” a file, if it is removed from the repository completely, or just going forward.
Any help is deeply appreciated!
Pro Git has a great, step-by-step explanation of how to do this. It takes a bit of work, but can be reliably done. I can’t take credit for the following explanation — I am just stealing it from that website (see the original website for a more detailed description):
Pack your repo:
Find the largest items in the git database. The following command will list the three biggest ones, with the biggest one being the last line of output (the example below includes both the command you would type and also sample output):
Ask what filename is associated with that biggest blob:
Get the history of that file:
Use
git filter-branchto remove all references to that file:Clean up a few remaining references to this blob, and then
gcagain to re-pack: