Delete the large files from repository
Asked by sunny386:

I have mistakenly committed the big files/folder in the repo and now the size of repo became 1.6GB, the actual size was around 75MB. I want to delete that folder from the repo. but it's not showing in the account or when I clone it again it is not there.

I want to reduce the size of the repo, can someone please help?

Repository name: appliedgeochemists.org


Answers:
author: Theodora Boudale
body: Hello,

I assume that the repository is hosted in Bitbucket Cloud (<https://bitbucket.org/>)?

Can you check the commits in Bitbucket website to find which commit contains these big files/folder?

If the commit that contains these large files is the last commit on a certain branch (no one else has pushed more commits to this branch), you can do a git reset on this branch, back to the commit before the large files were introduced, and force push this to Bitbucket.

In case the commit that contains these large files/folder is not the last commit on a certain branch and other people have pushed more commits, I would recommend rewriting repo history with a tool like BFG (<https://rtyley.github.io/bfg-repo-cleaner/>) to remove the large files/folder.

Please make sure to take a backup of the repo before either operation (since both include destructive operations) and communicate any steps you take with your team. Your team members may need to take a fresh clone of the repo afterwards if they have pulled the commit that has the large files/folder, so that they don't accidentally push this commit back.

Please also note that in both cases a git gc will be needed on the remote repo after you push your changes to Bitbucket, in order for the repo's size to get reduced. Feel free to let me know and I can run the git gc for you.

Please feel free to let me know if you have any questions.

Kind regards,  
Theodora

comments: author: sunny386
body: Hello, Thank you for the response.

Actually that commit had made by a team member, and while checking it in the commits I am unable to find out that commit and there is only one branch master.  
commit that included ./images (/images/Explore, /images/stories), that has over 1GB of images and pdfs. These need to be removed.

When I am cloning the repo again it is not showing these big files/folder in it. please help me to delete these big files I am new to the bitbucket.

Thank you.


author: Theodora Boudale
body: Hello,

I checked your account in our system, I found the repository with the name that you provided and I ran a git gc on it. After I ran the git gc, the repo's size is now 67.3 MB.

Since you mentioned that you couldn't find this commit and files, I believe that one of your colleagues may have already removed the problematic commit from the repo's history.

In this case, the commit remains on the remote repo as a dangling commit until a git gc runs, which I believe is the reason why the repo's size was showing as 1.7 GB.

Can you check the repo's size in the Repository settings and confirm if things are ok now?

Kind regards,  
Theodora


author: sunny386
body: Yes, I have checked the repository size, and its fine now.

Thank you so much for the help.

Regards,

Sunny


author: Theodora Boudale
body: Hi Sunny,

That's good to hear and you are very welcome! I'm glad this is sorted out now.

Kind regards,  
Theodora


author: sunny386
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) ,

I have an issue with another repository and posted it here <https://community.atlassian.com/t5/Bitbucket-questions/Delete-large-file-from-the-repository/qaq-p/1869681> but yet not gotten any response, can you please help me with this?

Thank you.


Tags: bitbucket-cloud