Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trying to reduce my repository size by reducing PACK file

Thejeswara Reddy R December 30, 2018

The Pack file in my repo is so bit like 10.8GB us showing kindly suggest me best way to  reduce the size of repo without losing the data

Git_Counts.PNG

Git pack file size as shown below

Git_pack.PNG

 

Thanks in advance!

 

1 answer

2 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 31, 2018

Hi Thejeswara!

Is that the size of your local repo? If so, there isn't really a trick, besides removing stuff from it. You could try running a Git gc and that might help removing some unnecessary files and references.

If you have binaries, you could also store them somewhere else, or use Git LFS. You can learn more about it at Git LFS.

Hope that helps!

Ana

Thejeswara Reddy R January 1, 2019

Hi Ana,

Thanks for quick responds!

The local repo full size is 13.4 GB but in that mostly occupied by pack file <10.8 GB> which I shown earlier.

Pack is in .git folder so when ever developer pull the the code it is taking huge time to download all 13.4 GB so we would like to remove the Pack file which is huge size.

 

Kindly reply ASAP.

 

Thanks & Regards,

Thejeswara

Thejeswara Reddy R January 7, 2019

Hello Ana,

 

Kindly provide me any alternate solution available or not?

 

Thanks & Regards,

Thejeswara

Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 7, 2019

Hi Thejeswara, first of all let's consider that we're running now into a Git question instead of a Bitbucket one.

Regarding Git repositories, you shouldn't try to remove individual pieces from them as this might end up corrupting them

The .pack file contains the actual Git objects. Git packs these objects in order to save space and be more efficient. Git does this if you have too many loose objects around, if you run the git gc command manually, or if you push to a remote server. For more info about this you can read Git internal packfiles and Unpacking Git packfiles.

If the size of your pack file is too large, you should look at what's in it, what kind of files are there in your repo? Do you have binary files, images, etc? If so, Git is not the right place to store them, depending on your case you should use Git LFS or keep those files somewhere else (like Dropbox, Google Drive, etc). To learn more, you can visit Tutorial Git LFS.

Let us know if you have any questions!

Ana

Thejeswara Reddy R January 7, 2019

Hi Ana,

Thanks for quick responds!

We already using Git LFS but the problem is when ever I do fresh git clone from repo it is taking much time because it contains huge file which is .pack file ~10GB.

 

So We would like to reduce the .pack file size, Is there any better way to reduce it?

 

Regards,

Thejeswara

Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 7, 2019

When you do a Git clone, it will create a copy of the whole repository, this includes the pack file as this is part of the repo too. The only way to reduce the size of the pack file will be by removing contents from your repo. What files do you have in there? Are all of them essential for the day-to-day work on this repo? Could some files be excluded?

AFAIK there's no magical way to reduce the size, you'll need to actually take things out or split the repo into several smaller repositories. 

Sorry I can not be of any more help here.

Best regards,

Ana

Fredrik Andersson _Infinera_
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 24, 2019

Hi Thejeswara,

Your pack is large since your history already committed to git is large. This probably happened before you started using LFS.

You have several options to manage this. Non however is problem free.

* Easiest is probably to use shallow clones.

* Split the repo in several pieces, and optionally create a graft when you need the full history.
I believe this is what was done for the Linux kernel repo, to keep it maintainable. (reference needed...?)
I have a nagging feeling that Bitbucket will behave badly on repos that are broken like this. Since the full history is not stored in the same repo. But there are settings you can use if you are running your own instance. 

* Migrate the hole repo to using LFS, including history
Problem with doing this is that all your commits will be rewritten and your old references to commits (SHA:s) will no longer be valid (branches and their names remain of course)
Atlassian have a tutorial for this here, that requires using an external tool called BFG. But there are several other ways of doing it. Search google for one that fits your experience.

 

Regards
Fredrik

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events