user1116573 user1116573 - 1 year ago 236
Git Question

Remove large .pack file created by git

I checked a load of files in to a branch and merged and then had to remove them and now I'm left with a large .pack file that I don't know how to get rid of.

I deleted all the files using

git rm -rf xxxxxx
and I also ran the
option as well.

Can someone tell me how I can remove a large .pack file that is currently in the following directory:


Do I just need to remove the branch that I still have but am no longer using? Or is there something else I need to run?

I'm not sure how much difference it makes but it shows a padlock against the file.



Here's some exerts from my bash_history that should give an idea how I managed to get into this state (assume at this point I'm working on a git branch called 'my-branch' and I've got a folder containing more folders/files):

git add .
git commit -m "Adding my branch changes to master"
git checkout master
git merge my-branch
git rm -rf unwanted_folder/
rm -rf unwanted_folder/ (not sure why I ran this as well but I did)

I thought I also ran the following but it doesn't appear in the bash_history with the others :

git rm -rf --cached unwanted_folder/

I also thought I ran some git commands (like
git gc
) to try to tidy up the pack file but they don't appear in the .bash_history file either.

Answer Source

One option:

run git gc manually to condense a number of pack files into one or a few pack files. This operation is persistent (i.e. the large pack file will retain its compression behavior) so it may be beneficial to compress a repository periodically with git gc --aggressive

Another option is to save the code and .git somewhere and then delete the .git and start again using this existing code, creating a new git repository (git init).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download