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
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)
git rm -rf --cached unwanted_folder/
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 (