I am new to git repository. I have a 2gb limit in bitbucket and bymistake I added one images
folder of 1.5 gb and pushed the code.
Now the bitbucket size is 1.8gb. To remove the folder from history I followed these steps.
Remove folder and its contents from git/GitHub's history
git filter-branch --tree-filter 'rm -rf import/images' --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git
update-ref -d
echo import/images/ >> .gitignore
git add .gitignore
git commit -m 'Removing images from git history'
git gc
git push origin master --force
I followed these steps and checked in my previous commits and the folder is removed. but git count-objects -v
still gives the size-pack of 1.8gb
Also in the bitbucket repository settings its still showing 1.8gb
Am I missing something?
You have to go to bitbucket page in order to delete a file/files.
You can't delete the folder like that (for some reason bitbucket allows only file delete and branch delete manually) but you can always empty the folder manually and remove it through console in the next git push.
Caution. This work like a "hard delete" so be extra careful when you use it, and don't use it if you can use git commands.
Edit
Have a look at this link there are quite a few options that may suit your problem.
Another approach is the git filter-branch --force. More about this command you can find here. This command is specifically for "rewriting" git history so it will do your job. It's tricky but it will do.
One last and final approach (never used this one to be honest) is 3rd party software (Really secure as even atlassian includes it in their documentation) but is in java so first you will need to install java in order to run a java command in your console. I saw your php tag so i just leave this as last just to concider it. I leave ths link here.