Git GC Remote
Asked by Gabriel Hillesheim da Silva:

Hy, I ran BFG over my repo, push all the files I've cloned with '--mirror', when I type

"git count-objects -v" I get this

count: 3  
size: 3  
in-pack: 1607  
packs: 1  
size-pack: 68472  
prune-packable: 0  
garbage: 0  
size-garbage: 0

But in BitBucket size information still warning me about the size.

'\<repo_name_removed\>' is the repo name.

How can this be solved?


Answers:
author: Theodora Boudale
body: Hi [@Gabriel Hillesheim da Silva](/t5/user/viewprofilepage/user-id/4529048) and welcome to the community.

I ran a git gc for this remote repository and its size is now 66.5 MB.

Is the warning gone now and is the size updated in the repository settings?

Just a heads up, I removed the repo name from your post for privacy reasons.

Kind regards,  
Theodora

comments: author: Gabriel Hillesheim da Silva
body: Hello,

Yes, the repo size is now updated, thank you !!

When necessary, is it always required to ask to run the git gc? Is there any configuration I can do to run automatically ?

Thank you!

Have nice day!


author: Theodora Boudale
body: Hi Gabriel,

Thank you for the update and you are very welcome, I'm glad to have helped!

There is an automated git gc that runs on every push, however, it runs with different options than the ones used when I manually ran it.

We have a Labs feature "Delete dangling commits when over size limit" that can be found here:

* <https://bitbucket.org/account/settings/features/>

This is useful when the repo goes over the size limit as a result of a large commit that you want to undo. In this case, if the Labs feature is enabled, you can reset to the commit prior to the large one, push to Bitbucket, and a git gc will run which will delete the large files you remove from history when you rewind your branch head. You can read more about this [here](https://support.atlassian.com/bitbucket-cloud/docs/reduce-repository-size/#Undoing-the-last-push).

If you rewrite a repo's history with BFG or git filter-branch, you'll need to post a question here and ask that we run a git gc, as the automated one doesn't remove the old references from the repo.

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

Kind regards,  
Theodora


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

I want to delete some large files from git history.   
The scenario is, those files were added accidentally in a feature branch and later I deleted them and commit again in the same branch. Now that branch has been merged to master and got deleted. We have multiple commits and PRs merged to master after that bad commit.

As those files are still there in git history, they are consuming space in bitbucket and I am getting warning for that.

I was trying to find out a mechanism to delete those files from that commit#.  

BFG tool is doing the needful but there are few concerns:  

1. approx 50 folks are working on this repo  
2. there are Jira tickets having commit# and PRs, and if we use BFG, that will rewrite history and create new commit #. In that case, we need to update those Jira tickets with correct commit# (Jira tickets count is unknown)  
3. bad commit was done on 19th August 2021 and we have multiple PRs merged and branches created after that

Please suggest if there is a better way to do, addressing above points.


author: Theodora Boudale
body: Hi [@Swati Singh](/t5/user/viewprofilepage/user-id/4550951),

A new question was posted with similar concerns here:

* <https://community.atlassian.com/t5/Bitbucket-questions/Delete-large-files-from-git-history-without-breaking-Commit-and/qaq-p/1800970>

I'm not sure if the question was created by one of your team members or not? You can check what I have responded there and let me know if you have any questions.

Kind regards,  
Theodora


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

Yes that ticket was raised by my team member. Thanks for your response.

Regards,  
Swati


Tags: bitbucket-cloud

cloud

garbage-collection

git